summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorMathieu Arnold <mat@FreeBSD.org>2014-01-04 14:33:12 +0000
committerMathieu Arnold <mat@FreeBSD.org>2014-01-04 14:33:12 +0000
commitf9902a1f64a1ea967e3213ab2856b11fac23c03d (patch)
treeb805f49f10b326276206fe3fe63fa9178c6758f1 /java
parent- Fix packaging of examples after move to PYDISTUTILS_AUTOPLIST (diff)
Revert lang/openjdk6 to b28.
With hat: portmgr-lurker
Notes
Notes: svn path=/head/; revision=338646
Diffstat (limited to 'java')
-rw-r--r--java/openjdk6-jre/Makefile2
-rw-r--r--java/openjdk6/Makefile17
-rw-r--r--java/openjdk6/Makefile.icedtea104
-rw-r--r--java/openjdk6/distinfo4
-rw-r--r--java/openjdk6/files/icedtea/openjdk/4075303-javap_update.patch12081
-rw-r--r--java/openjdk6/files/icedtea/openjdk/4111861-static_fields.patch280
-rw-r--r--java/openjdk6/files/icedtea/openjdk/4501661-disallow_mixing.patch222
-rw-r--r--java/openjdk6/files/icedtea/openjdk/4884240-javap_additional_option.patch288
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6708729-javap_makefile_update.patch59
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6715767-javap_crash.patch135
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6819246-javap_instruction_decoding.patch2065
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6824493-experimental.patch1304
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6841419-classfile_iterator.patch142
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6841420-classfile_methods.patch34
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6843013-missing_experimental.patch334
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6852856-javap_subclasses.patch508
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6867671-javap_whitespace.patch1041
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6868539-constant_pool_tags.patch163
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6902264-fix_indentation.patch159
-rw-r--r--java/openjdk6/files/icedtea/openjdk/6954275-big_xml_signatures.patch194
-rw-r--r--java/openjdk6/files/icedtea/openjdk/7146431-java.security_files.patch82
-rw-r--r--java/openjdk6/files/icedtea/openjdk/7196533-timezone_bottleneck.patch75
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8000450-restrict_access.patch108
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8002070-remove_logger_stack_search.patch658
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8003992-embedded_nulls.patch1026
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8004188-rename_java.security.patch652
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8006882-jmockit.patch90
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8006900-new_date_time.patch115
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8008589-better_mbean_permission_validation.patch61
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8010118-caller_sensitive.patch2968
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8010727-empty_logger_name.patch101
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8010939-logmanager_deadlock.patch266
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8011071-better_crypto_provider_handling.patch287
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8011081-improve_jhat.patch267
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8011139-revise_checking_getenclosingclass.patch58
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8011157-improve_corba_portability-jdk.patch125
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8011157-improve_corba_portability.patch183
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8011990-logger_test_urls.patch58
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8012071-better_bean_building.patch87
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8012147-improve_tool.patch55
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8012243-serial_regression.patch45
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8012277-improve_dataflavour.patch83
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8012425-transform_transformfactory.patch380
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8012453-runtime.exec.patch383
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8012617-arrayindexoutofbounds_linebreakmeasurer.patch515
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8013380-logger_stack_walk_glassfish.patch941
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8013503-improve_stream_factories.patch224
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8013506-better_pack200.patch39
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8013510-augment_image_writing.patch57
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8013514-improve_cmap_stability.patch51
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8013739-better_ldap_resource_management.patch148
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8013744-better_tabling.patch196
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8013827-createtempfile_hang.patch176
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014085-better_serialization.patch412
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014093-improve_image_parsing.patch719
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014102-improve_image_conversion.patch190
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014341-better_kerberos_service.patch66
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014349-getdeclaredclass_fix.patch43
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014530-better_dsp.patch3121
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014534-better_profiling.patch156
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014718-remove_logging_suntoolkit.patch115
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014745-logger_stack_walk_switch.patch205
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8014987-augment_serialization.patch100
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8015144-performance_regression.patch273
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8015614-update_build.patch60
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8015731-auth_improvements.patch28
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8015743-address_internet_addresses.patch1290
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8015965-typo_in_property_name.patch42
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8015978-incorrect_transformation.patch22
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8016256-finalization_final.patch24
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8016357-update_hs_diagnostic_class.patch71
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8016653-ignoreable_characters.patch101
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8016675-robust_javadoc.patch75
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8017196-ensure_proxies_are_handled_appropriately-jdk.patch107
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8017196-ensure_proxies_are_handled_appropriately.patch94
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8017287-better_resource_disposal.patch22
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8017291-cast_proxies_aside.patch34
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8017298-better_xml_support.patch999
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8017300-improve_interface_implementation.patch129
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8017505-better_client_service.patch560
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8017566-backout_part_of_8000450.patch77
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8019292-better_attribute_value_exceptions.patch57
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8019584-invalid_notification_fix.patch69
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8019617-better_view_of_objects.patch68
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8019969-inet6_test_case_fix.patch33
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8019979-better_access_test.patch154
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8020293-jvm_crash.patch40
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8020943-memory_leak.patch32
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8021290-signature_validation.patch55
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8021355-splashscreen_regression.patch53
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8021366-jaxp_test_fix-01.patch21
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8021577-bean_serialization_fix.patch25
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8021933-jaxp_test_fix-02.patch33
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8021969-jnlp_load_failure.patch25
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8022661-writeobject_flush.patch20
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8022682-supporting_xom.patch250
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8022940-enhance_corba_translations.patch41
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8023457-tracing_mutex.patch79
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8023478-hs_crash.patch21
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8023683-enhance_class_file_parsing.patch35
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8023964-ignore_test.patch29
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8024914-swapped_usage.patch58
-rw-r--r--java/openjdk6/files/icedtea/openjdk/8025128-createtempfile_absolute_prefix.patch139
-rw-r--r--java/openjdk6/files/icedtea/openjdk/oj6-19-fix_8010118_test_cases.patch499
-rw-r--r--java/openjdk6/files/icedtea/openjdk/oj6-20-merge.patch599
-rw-r--r--java/openjdk6/files/icedtea/openjdk/oj6-21-overrides.patch20
-rw-r--r--java/openjdk6/files/patch-set273
107 files changed, 41295 insertions, 264 deletions
diff --git a/java/openjdk6-jre/Makefile b/java/openjdk6-jre/Makefile
index 2ba20c72c8b2..e4b23891c21f 100644
--- a/java/openjdk6-jre/Makefile
+++ b/java/openjdk6-jre/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-PORTREVISION= 0
+PORTREVISION= 7
CATEGORIES= java devel
PKGNAMESUFFIX= -jre
diff --git a/java/openjdk6/Makefile b/java/openjdk6/Makefile
index 7cd37e9a9b35..9accef50b18f 100644
--- a/java/openjdk6/Makefile
+++ b/java/openjdk6/Makefile
@@ -2,12 +2,13 @@
# $FreeBSD$
PORTNAME= openjdk6
-PORTVERSION= b29
-PORTREVISION?= 0
+PORTVERSION= b28
+PORTREVISION?= 7
+PORTEPOCH= 1
CATEGORIES= java devel
MASTER_SITES= ${MASTER_SITE_APACHE:S,%SUBDIR%/,ant/binaries/:ant,} \
http://download.java.net/openjdk/jtreg/promoted/4.1/b05/:jtreg \
- https://java.net/downloads/openjdk6/ \
+ https://java.net/projects/openjdk6/downloads/download/ \
LOCAL
MASTER_SITE_SUBDIR= jkim
DISTNAME= openjdk-6-src-${PORTVERSION}-${OPENJDK_BUILDDATE}
@@ -18,8 +19,6 @@ EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} ${ANTFILE}
MAINTAINER= java@FreeBSD.org
COMMENT?= Oracle's Java 6 virtual machine release under the GPL v2
-FORBIDDEN= Triggering a nasty FreeBSD bug
-
LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/LICENSE
LICENSE_DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
@@ -31,7 +30,7 @@ LIB_DEPENDS= libfreetype.so:${PORTSDIR}/print/freetype2
RUN_DEPENDS= javavm:${PORTSDIR}/java/javavmwrapper \
${LOCALBASE}/lib/X11/fonts/dejavu:${PORTSDIR}/x11-fonts/dejavu
-OPENJDK_BUILDDATE= 05_dec_2013
+OPENJDK_BUILDDATE= 04_oct_2013
OPTIONS_DEFINE= ICEDTEA IPV6 POLICY SOUND TZUPDATE
OPTIONS_DEFAULT=ICEDTEA IPV6 TZUPDATE
@@ -229,12 +228,6 @@ post-patch:
@${REINPLACE_CMD} -e "s|%%CXX_LIBS%%|${CXX_LIBS}|" \
${WRKSRC}/corba/make/common/Defs-bsd.gmk \
${WRKSRC}/jdk/make/common/Defs-bsd.gmk
-.if ${COMPILER_TYPE} == "clang"
- @${REINPLACE_CMD} -e "s|-fno-omit-frame-pointer|-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer|" \
- ${WRKSRC}/corba/make/common/Defs-bsd.gmk \
- ${WRKSRC}/hotspot/make/bsd/makefiles/amd64.make \
- ${WRKSRC}/jdk/make/common/Defs-bsd.gmk
-.endif
@${REINPLACE_CMD} -e "s|%%ICONV_INC%%|${ICONV_INCLUDE}|" \
-e "s|%%ICONV_LIB%%|${ICONV_LIBS}|" \
${WRKSRC}/Makefile ${WRKSRC}/jdk/make/java/instrument/Makefile \
diff --git a/java/openjdk6/Makefile.icedtea b/java/openjdk6/Makefile.icedtea
index 7f82e65ff79e..00046b304ed5 100644
--- a/java/openjdk6/Makefile.icedtea
+++ b/java/openjdk6/Makefile.icedtea
@@ -1,6 +1,108 @@
# $FreeBSD$
-_PATCHES=
+_PATCHES= \
+ openjdk/8017196-ensure_proxies_are_handled_appropriately.patch \
+ openjdk/8011157-improve_corba_portability.patch \
+ openjdk/8022940-enhance_corba_translations.patch \
+ openjdk/8013503-improve_stream_factories.patch \
+ openjdk/8012425-transform_transformfactory.patch \
+ openjdk/8017298-better_xml_support.patch \
+ openjdk/8014530-better_dsp.patch \
+ openjdk/8021366-jaxp_test_fix-01.patch \
+ openjdk/8021933-jaxp_test_fix-02.patch \
+ openjdk/8022682-supporting_xom.patch \
+ openjdk/8015978-incorrect_transformation.patch \
+ openjdk/oj6-20-merge.patch \
+ openjdk/8024914-swapped_usage.patch \
+ openjdk/8017505-better_client_service.patch \
+ openjdk/8015614-update_build.patch \
+ openjdk/8016256-finalization_final.patch \
+ openjdk/8023683-enhance_class_file_parsing.patch \
+ openjdk/8023457-tracing_mutex.patch \
+ openjdk/8020943-memory_leak.patch \
+ openjdk/8023478-hs_crash.patch \
+ openjdk/4075303-javap_update.patch \
+ openjdk/6819246-javap_instruction_decoding.patch \
+ openjdk/6715767-javap_crash.patch \
+ openjdk/6841420-classfile_methods.patch \
+ openjdk/6841419-classfile_iterator.patch \
+ openjdk/4111861-static_fields.patch \
+ openjdk/4884240-javap_additional_option.patch \
+ openjdk/6852856-javap_subclasses.patch \
+ openjdk/6867671-javap_whitespace.patch \
+ openjdk/6868539-constant_pool_tags.patch \
+ openjdk/4501661-disallow_mixing.patch \
+ openjdk/6824493-experimental.patch \
+ openjdk/6843013-missing_experimental.patch \
+ openjdk/6902264-fix_indentation.patch \
+ openjdk/8016675-robust_javadoc.patch \
+ openjdk/8016653-ignoreable_characters.patch \
+ openjdk/7196533-timezone_bottleneck.patch \
+ openjdk/8006900-new_date_time.patch \
+ openjdk/8008589-better_mbean_permission_validation.patch \
+ openjdk/8011071-better_crypto_provider_handling.patch \
+ openjdk/8011081-improve_jhat.patch \
+ openjdk/8011157-improve_corba_portability-jdk.patch \
+ openjdk/8012071-better_bean_building.patch \
+ openjdk/8012147-improve_tool.patch \
+ openjdk/8012277-improve_dataflavour.patch \
+ openjdk/8013506-better_pack200.patch \
+ openjdk/8013510-augment_image_writing.patch \
+ openjdk/8013514-improve_cmap_stability.patch \
+ openjdk/8013744-better_tabling.patch \
+ openjdk/8014085-better_serialization.patch \
+ openjdk/8014093-improve_image_parsing.patch \
+ openjdk/8014102-improve_image_conversion.patch \
+ openjdk/8014341-better_kerberos_service.patch \
+ openjdk/8014534-better_profiling.patch \
+ openjdk/8014987-augment_serialization.patch \
+ openjdk/8015731-auth_improvements.patch \
+ openjdk/8015743-address_internet_addresses.patch \
+ openjdk/8016357-update_hs_diagnostic_class.patch \
+ openjdk/8002070-remove_logger_stack_search.patch \
+ openjdk/6708729-javap_makefile_update.patch \
+ openjdk/8010118-caller_sensitive.patch \
+ openjdk/oj6-19-fix_8010118_test_cases.patch \
+ openjdk/8010727-empty_logger_name.patch \
+ openjdk/8010939-logmanager_deadlock.patch \
+ openjdk/8011990-logger_test_urls.patch \
+ openjdk/8013380-logger_stack_walk_glassfish.patch \
+ openjdk/8014745-logger_stack_walk_switch.patch \
+ openjdk/8012243-serial_regression.patch \
+ openjdk/8014718-remove_logging_suntoolkit.patch \
+ openjdk/8011139-revise_checking_getenclosingclass.patch \
+ openjdk/8017196-ensure_proxies_are_handled_appropriately-jdk.patch \
+ openjdk/8017287-better_resource_disposal.patch \
+ openjdk/8017291-cast_proxies_aside.patch \
+ openjdk/7146431-java.security_files.patch \
+ openjdk/8006882-jmockit.patch \
+ openjdk/8000450-restrict_access.patch \
+ openjdk/8019979-better_access_test.patch \
+ openjdk/8004188-rename_java.security.patch \
+ openjdk/8017566-backout_part_of_8000450.patch \
+ openjdk/8017300-improve_interface_implementation.patch \
+ openjdk/8019292-better_attribute_value_exceptions.patch \
+ openjdk/8019617-better_view_of_objects.patch \
+ openjdk/8012617-arrayindexoutofbounds_linebreakmeasurer.patch \
+ openjdk/8020293-jvm_crash.patch \
+ openjdk/8013739-better_ldap_resource_management.patch \
+ openjdk/8014349-getdeclaredclass_fix.patch \
+ openjdk/6954275-big_xml_signatures.patch \
+ openjdk/8021290-signature_validation.patch \
+ openjdk/8012453-runtime.exec.patch \
+ openjdk/8015965-typo_in_property_name.patch \
+ openjdk/8015144-performance_regression.patch \
+ openjdk/8019969-inet6_test_case_fix.patch \
+ openjdk/8019584-invalid_notification_fix.patch \
+ openjdk/8021577-bean_serialization_fix.patch \
+ openjdk/8021969-jnlp_load_failure.patch \
+ openjdk/8021355-splashscreen_regression.patch \
+ openjdk/8022661-writeobject_flush.patch \
+ openjdk/8023964-ignore_test.patch \
+ openjdk/8003992-embedded_nulls.patch \
+ openjdk/8013827-createtempfile_hang.patch \
+ openjdk/8025128-createtempfile_absolute_prefix.patch \
+ openjdk/oj6-21-overrides.patch
.if ${PORT_OPTIONS:MICEDTEA}
_PATCHES+= \
diff --git a/java/openjdk6/distinfo b/java/openjdk6/distinfo
index 3043653fcd0c..81924ecba06a 100644
--- a/java/openjdk6/distinfo
+++ b/java/openjdk6/distinfo
@@ -1,6 +1,6 @@
SHA256 (apache-ant-1.9.2-bin.tar.bz2) = bfe3a90de898d583510d670ae9ea2adb2874aa1567e21a83de2f363474fc9a24
SIZE (apache-ant-1.9.2-bin.tar.bz2) = 4310740
-SHA256 (openjdk-6-src-b29-05_dec_2013.tar.gz) = a9b1b0a48fb52aef82bbe5db33b1dae1672fc8a5f456451f2e300158fc7a7d6b
-SIZE (openjdk-6-src-b29-05_dec_2013.tar.gz) = 53754194
+SHA256 (openjdk-6-src-b28-04_oct_2013.tar.gz) = ac4fceed060ad61dab938c41181455fb0910f58f6944f820f0637b0f0c64bf75
+SIZE (openjdk-6-src-b28-04_oct_2013.tar.gz) = 53599044
SHA256 (jtreg-4.1-bin-b05_29_nov_2012.zip) = 9291eb4a14501232b35614e88686ff66ad8b69d0098dbd4322b28f97b672653d
SIZE (jtreg-4.1-bin-b05_29_nov_2012.zip) = 5993382
diff --git a/java/openjdk6/files/icedtea/openjdk/4075303-javap_update.patch b/java/openjdk6/files/icedtea/openjdk/4075303-javap_update.patch
new file mode 100644
index 000000000000..5123d6cf1e59
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/4075303-javap_update.patch
@@ -0,0 +1,12081 @@
+# HG changeset patch
+# User jjg
+# Date 1382400229 -3600
+# Tue Oct 22 01:03:49 2013 +0100
+# Node ID bfd7bb4218253bac4f57abbc90b987f16e4b7f6c
+# Parent 8e38c8fe0a0beaef943e754071be0358c34e76dd
+4075303: Use javap to enquire about a specific inner class
+4348375: Javap is not internationalized
+4459541: "javap -l" shows line numbers as signed short; they should be unsigned
+4501660: change diagnostic of -help as 'print this help message and exit'
+4776241: unused source file in javap...
+4870651: javap should recognize generics, varargs, enum
+4876942: javap invoked without args does not print help screen
+4880663: javap could output whitespace between class name and opening brace
+4975569: javap doesn't print new flag bits
+6271787: javap dumps LocalVariableTypeTable attribute in hex, needs to print a table
+6305779: javap: support annotations
+6439940: Clean up javap implementation
+6469569: wrong check of searchpath in JavapEnvironment
+6474890: javap does not open .zip files in -classpath
+6587786: Javap throws error : "ERROR:Could not find <classname>" for JRE classes
+6622215: javap ignores certain relevant access flags
+6622216: javap names some attributes incorrectly
+6622232: javap gets whitespace confused
+6622260: javap prints negative bytes incorrectly in hex
+Reviewed-by: ksrini
+
+diff -r 8e38c8fe0a0b -r bfd7bb421825 make/build.properties
+--- langtools/make/build.properties Fri Oct 04 12:22:34 2013 -0400
++++ langtools/make/build.properties Tue Oct 22 01:03:49 2013 +0100
+@@ -130,6 +130,8 @@
+ #
+
+ javap.includes = \
++ com/sun/tools/classfile/ \
++ com/sun/tools/javap/ \
+ sun/tools/javap/
+
+ javap.tests = \
+diff -r 8e38c8fe0a0b -r bfd7bb421825 make/build.xml
+--- langtools/make/build.xml Fri Oct 04 12:22:34 2013 -0400
++++ langtools/make/build.xml Tue Oct 22 01:03:49 2013 +0100
+@@ -316,14 +316,15 @@
+ jarmainclass="sun.tools.javap.Main"/>
+ </target>
+
+- <target name="build-classes-javap" depends="build-bootstrap-javac">
++ <target name="build-classes-javap" depends="build-classes-javac">
+ <build-classes name="javap" includes="${javap.includes}"/>
+ </target>
+
+- <target name="build-javap" depends="build-bootstrap-javac">
++ <target name="build-javap" depends="build-javac">
+ <build-tool name="javap"
+ includes="${javap.includes}"
+- jarmainclass="sun.tools.javap.Main"/>
++ jarmainclass="sun.tools.javap.Main"
++ jarclasspath="javac.jar"/>
+ </target>
+
+ <!-- (no javadoc for javap) -->
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/AccessFlags.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/AccessFlags.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,254 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++import java.util.LinkedHashSet;
++import java.util.Set;
++
++/**
++ * See JVMS3, sections 4.2, 4.6, 4.7.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class AccessFlags {
++ public static final int ACC_PUBLIC = 0x0001; // class, inner, field, method
++ public static final int ACC_PRIVATE = 0x0002; // inner, field, method
++ public static final int ACC_PROTECTED = 0x0004; // inner, field, method
++ public static final int ACC_STATIC = 0x0008; // inner, field, method
++ public static final int ACC_FINAL = 0x0010; // class, inner, field, method
++ public static final int ACC_SUPER = 0x0020; // class
++ public static final int ACC_SYNCHRONIZED = 0x0020; // method
++ public static final int ACC_VOLATILE = 0x0040; // field
++ public static final int ACC_BRIDGE = 0x0040; // method
++ public static final int ACC_TRANSIENT = 0x0080; // field
++ public static final int ACC_VARARGS = 0x0080; // method
++ public static final int ACC_NATIVE = 0x0100; // method
++ public static final int ACC_INTERFACE = 0x0200; // class, inner
++ public static final int ACC_ABSTRACT = 0x0400; // class, inner, method
++ public static final int ACC_STRICT = 0x0800; // method
++ public static final int ACC_SYNTHETIC = 0x1000; // class, inner, field, method
++ public static final int ACC_ANNOTATION = 0x2000; // class, inner
++ public static final int ACC_ENUM = 0x4000; // class, inner, field
++ public static final int ACC_MODULE = 0x8000; // class, inner, field, method
++
++ private static enum Type { Class, InnerClass, Field, Method};
++
++ AccessFlags(ClassReader cr) throws IOException {
++ this(cr.readUnsignedShort());
++ }
++
++ public AccessFlags(int flags) {
++ this.flags = flags;
++ }
++
++ public AccessFlags ignore(int mask) {
++ return new AccessFlags(flags & ~mask);
++ }
++
++ public boolean is(int mask) {
++ return (flags & mask) != 0;
++ }
++
++ private static final int[] classModifiers = {
++ ACC_PUBLIC, ACC_FINAL, ACC_ABSTRACT, ACC_MODULE
++ };
++
++ private static final int[] classFlags = {
++ ACC_PUBLIC, ACC_FINAL, ACC_SUPER, ACC_INTERFACE, ACC_ABSTRACT,
++ ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM, ACC_MODULE
++ };
++
++ public Set<String> getClassModifiers() {
++ int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags);
++ return getModifiers(f, classModifiers, Type.Class);
++ }
++
++ public Set<String> getClassFlags() {
++ return getFlags(classFlags, Type.Class);
++ }
++
++ private static final int[] innerClassModifiers = {
++ ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
++ ACC_ABSTRACT, ACC_MODULE
++ };
++
++ private static final int[] innerClassFlags = {
++ ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SUPER,
++ ACC_INTERFACE, ACC_ABSTRACT, ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM, ACC_MODULE
++ };
++
++ public Set<String> getInnerClassModifiers() {
++ int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags);
++ return getModifiers(f, innerClassModifiers, Type.InnerClass);
++ }
++
++ public Set<String> getInnerClassFlags() {
++ return getFlags(innerClassFlags, Type.InnerClass);
++ }
++
++ private static final int[] fieldModifiers = {
++ ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
++ ACC_VOLATILE, ACC_TRANSIENT, ACC_MODULE
++ };
++
++ private static final int[] fieldFlags = {
++ ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
++ ACC_VOLATILE, ACC_TRANSIENT, ACC_SYNTHETIC, ACC_ENUM, ACC_MODULE
++ };
++
++ public Set<String> getFieldModifiers() {
++ return getModifiers(fieldModifiers, Type.Field);
++ }
++
++ public Set<String> getFieldFlags() {
++ return getFlags(fieldFlags, Type.Field);
++ }
++
++ private static final int[] methodModifiers = {
++ ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
++ ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT, ACC_MODULE
++ };
++
++ private static final int[] methodFlags = {
++ ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,
++ ACC_SYNCHRONIZED, ACC_BRIDGE, ACC_VARARGS, ACC_NATIVE, ACC_ABSTRACT,
++ ACC_STRICT, ACC_SYNTHETIC, ACC_MODULE
++ };
++
++ public Set<String> getMethodModifiers() {
++ return getModifiers(methodModifiers, Type.Method);
++ }
++
++ public Set<String> getMethodFlags() {
++ return getFlags(methodFlags, Type.Method);
++ }
++
++ private Set<String> getModifiers(int[] modifierFlags, Type t) {
++ return getModifiers(flags, modifierFlags, t);
++ }
++
++ private static Set<String> getModifiers(int flags, int[] modifierFlags, Type t) {
++ Set<String> s = new LinkedHashSet<String>();
++ for (int m: modifierFlags) {
++ if ((flags & m) != 0)
++ s.add(flagToModifier(m, t));
++ }
++ return s;
++ }
++
++ private Set<String> getFlags(int[] expectedFlags, Type t) {
++ Set<String> s = new LinkedHashSet<String>();
++ int f = flags;
++ for (int e: expectedFlags) {
++ if ((f & e) != 0) {
++ s.add(flagToName(e, t));
++ f = f & ~e;
++ }
++ }
++ while (f != 0) {
++ int bit = Integer.highestOneBit(f);
++ s.add("0x" + Integer.toHexString(bit));
++ f = f & ~bit;
++ }
++ return s;
++ }
++
++ private static String flagToModifier(int flag, Type t) {
++ switch (flag) {
++ case ACC_PUBLIC:
++ return "public";
++ case ACC_PRIVATE:
++ return "private";
++ case ACC_PROTECTED:
++ return "protected";
++ case ACC_STATIC:
++ return "static";
++ case ACC_FINAL:
++ return "final";
++ case ACC_SYNCHRONIZED:
++ return "synchronized";
++ case 0x80:
++ return (t == Type.Field ? "transient" : null);
++ case ACC_VOLATILE:
++ return "volatile";
++ case ACC_NATIVE:
++ return "native";
++ case ACC_ABSTRACT:
++ return "abstract";
++ case ACC_STRICT:
++ return "strictfp";
++ case ACC_MODULE:
++ return "module";
++ default:
++ return null;
++ }
++ }
++
++ private static String flagToName(int flag, Type t) {
++ switch (flag) {
++ case ACC_PUBLIC:
++ return "ACC_PUBLIC";
++ case ACC_PRIVATE:
++ return "ACC_PRIVATE";
++ case ACC_PROTECTED:
++ return "ACC_PROTECTED";
++ case ACC_STATIC:
++ return "ACC_STATIC";
++ case ACC_FINAL:
++ return "ACC_FINAL";
++ case 0x20:
++ return (t == Type.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED");
++ case 0x40:
++ return (t == Type.Field ? "ACC_VOLATILE" : "ACC_BRIDGE");
++ case 0x80:
++ return (t == Type.Field ? "ACC_TRANSIENT" : "ACC_VARARGS");
++ case ACC_NATIVE:
++ return "ACC_NATIVE";
++ case ACC_INTERFACE:
++ return "ACC_INTERFACE";
++ case ACC_ABSTRACT:
++ return "ACC_ABSTRACT";
++ case ACC_STRICT:
++ return "ACC_STRICT";
++ case ACC_SYNTHETIC:
++ return "ACC_SYNTHETIC";
++ case ACC_ANNOTATION:
++ return "ACC_ANNOTATION";
++ case ACC_ENUM:
++ return "ACC_ENUM";
++ case ACC_MODULE:
++ return "ACC_MODULE";
++ default:
++ return null;
++ }
++ }
++
++ final int flags;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Annotation.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Annotation.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,243 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.16.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Annotation {
++ static class InvalidAnnotation extends AttributeException {
++ InvalidAnnotation(String msg) {
++ super(msg);
++ }
++ }
++
++ Annotation(ClassReader cr) throws IOException, InvalidAnnotation {
++ type_index = cr.readUnsignedShort();
++ num_element_value_pairs = cr.readUnsignedShort();
++ element_value_pairs = new element_value_pair[num_element_value_pairs];
++ for (int i = 0; i < element_value_pairs.length; i++)
++ element_value_pairs[i] = new element_value_pair(cr);
++ }
++
++ public Annotation(ConstantPool constant_pool,
++ int type_index,
++ element_value_pair[] element_value_pairs) {
++ this.type_index = type_index;
++ num_element_value_pairs = element_value_pairs.length;
++ this.element_value_pairs = element_value_pairs;
++ }
++
++ public int length() {
++ int n = 2 /*type_index*/ + 2 /*num_element_value_pairs*/;
++ for (element_value_pair pair: element_value_pairs)
++ n += pair.length();
++ return n;
++ }
++
++ public final int type_index;
++ public final int num_element_value_pairs;
++ public final element_value_pair element_value_pairs[];
++
++ /**
++ * See JVMS3, section 4.8.16.1.
++ */
++ public static abstract class element_value {
++ public static element_value read(ClassReader cr)
++ throws IOException, InvalidAnnotation {
++ int tag = cr.readUnsignedByte();
++ switch (tag) {
++ case 'B':
++ case 'C':
++ case 'D':
++ case 'F':
++ case 'I':
++ case 'J':
++ case 'S':
++ case 'Z':
++ case 's':
++ return new Primitive_element_value(cr, tag);
++
++ case 'e':
++ return new Enum_element_value(cr, tag);
++
++ case 'c':
++ return new Class_element_value(cr, tag);
++
++ case '@':
++ return new Annotation_element_value(cr, tag);
++
++ case '[':
++ return new Array_element_value(cr, tag);
++
++ default:
++ throw new InvalidAnnotation("unrecognized tag: " + tag);
++ }
++ }
++
++ protected element_value(int tag) {
++ this.tag = tag;
++ }
++
++ public abstract int length();
++
++ public abstract <R,P> R accept(Visitor<R,P> visitor, P p);
++
++ public interface Visitor<R,P> {
++ R visitPrimitive(Primitive_element_value ev, P p);
++ R visitEnum(Enum_element_value ev, P p);
++ R visitClass(Class_element_value ev, P p);
++ R visitAnnotation(Annotation_element_value ev, P p);
++ R visitArray(Array_element_value ev, P p);
++ }
++
++ public final int tag;
++ }
++
++ public static class Primitive_element_value extends element_value {
++ Primitive_element_value(ClassReader cr, int tag) throws IOException {
++ super(tag);
++ const_value_index = cr.readUnsignedShort();
++ }
++
++ @Override
++ public int length() {
++ return 2;
++ }
++
++ public <R,P> R accept(Visitor<R,P> visitor, P p) {
++ return visitor.visitPrimitive(this, p);
++ }
++
++ public final int const_value_index;
++
++ }
++
++ public static class Enum_element_value extends element_value {
++ Enum_element_value(ClassReader cr, int tag) throws IOException {
++ super(tag);
++ type_name_index = cr.readUnsignedShort();
++ const_name_index = cr.readUnsignedShort();
++ }
++
++ @Override
++ public int length() {
++ return 4;
++ }
++
++ public <R,P> R accept(Visitor<R,P> visitor, P p) {
++ return visitor.visitEnum(this, p);
++ }
++
++ public final int type_name_index;
++ public final int const_name_index;
++ }
++
++ public static class Class_element_value extends element_value {
++ Class_element_value(ClassReader cr, int tag) throws IOException {
++ super(tag);
++ class_info_index = cr.readUnsignedShort();
++ }
++
++ @Override
++ public int length() {
++ return 2;
++ }
++
++ public <R,P> R accept(Visitor<R,P> visitor, P p) {
++ return visitor.visitClass(this, p);
++ }
++
++ public final int class_info_index;
++ }
++
++ public static class Annotation_element_value extends element_value {
++ Annotation_element_value(ClassReader cr, int tag)
++ throws IOException, InvalidAnnotation {
++ super(tag);
++ annotation_value = new Annotation(cr);
++ }
++
++ @Override
++ public int length() {
++ return annotation_value.length();
++ }
++
++ public <R,P> R accept(Visitor<R,P> visitor, P p) {
++ return visitor.visitAnnotation(this, p);
++ }
++
++ public final Annotation annotation_value;
++ }
++
++ public static class Array_element_value extends element_value {
++ Array_element_value(ClassReader cr, int tag)
++ throws IOException, InvalidAnnotation {
++ super(tag);
++ num_values = cr.readUnsignedShort();
++ values = new element_value[num_values];
++ for (int i = 0; i < values.length; i++)
++ values[i] = element_value.read(cr);
++ }
++
++ @Override
++ public int length() {
++ int n = 2;
++ for (int i = 0; i < values.length; i++)
++ n += values[i].length();
++ return n;
++ }
++
++ public <R,P> R accept(Visitor<R,P> visitor, P p) {
++ return visitor.visitArray(this, p);
++ }
++
++ public final int num_values;
++ public final element_value[] values;
++ }
++
++ public static class element_value_pair {
++ element_value_pair(ClassReader cr)
++ throws IOException, InvalidAnnotation {
++ element_name_index = cr.readUnsignedShort();
++ value = element_value.read(cr);
++ }
++
++ public int length() {
++ return 2 + value.length();
++ }
++
++ public final int element_name_index;
++ public final element_value value;
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/AnnotationDefault_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/AnnotationDefault_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,61 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.15.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class AnnotationDefault_attribute extends Attribute {
++ AnnotationDefault_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, Annotation.InvalidAnnotation {
++ super(name_index, length);
++ default_value = Annotation.element_value.read(cr);
++ }
++
++ public AnnotationDefault_attribute(ConstantPool constant_pool, Annotation.element_value default_value)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.AnnotationDefault), default_value);
++ }
++
++ public AnnotationDefault_attribute(int name_index, Annotation.element_value default_value) {
++ super(name_index, default_value.length());
++ this.default_value = default_value;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitAnnotationDefault(this, data);
++ }
++
++ public final Annotation.element_value default_value;
++}
++
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,199 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++import java.lang.reflect.Constructor;
++import java.util.HashMap;
++import java.util.Map;
++
++/**
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++
++public abstract class Attribute {
++ public static final String AnnotationDefault = "AnnotationDefault";
++ public static final String CharacterRangeTable = "CharacterRangeTable";
++ public static final String Code = "Code";
++ public static final String ConstantValue = "ConstantValue";
++ public static final String CompilationID = "CompilationID";
++ public static final String Deprecated = "Deprecated";
++ public static final String EnclosingMethod = "EnclosingMethod";
++ public static final String Exceptions = "Exceptions";
++ public static final String InnerClasses = "InnerClasses";
++ public static final String LineNumberTable = "LineNumberTable";
++ public static final String LocalVariableTable = "LocalVariableTable";
++ public static final String LocalVariableTypeTable = "LocalVariableTypeTable";
++ public static final String RuntimeVisibleAnnotations = "RuntimeVisibleAnnotations";
++ public static final String RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations";
++ public static final String RuntimeVisibleParameterAnnotations = "RuntimeVisibleParameterAnnotations";
++ public static final String RuntimeInvisibleParameterAnnotations = "RuntimeInvisibleParameterAnnotations";
++ public static final String Signature = "Signature";
++ public static final String SourceDebugExtension = "SourceDebugExtension";
++ public static final String SourceFile = "SourceFile";
++ public static final String SourceID = "SourceID";
++ public static final String StackMap = "StackMap";
++ public static final String StackMapTable = "StackMapTable";
++ public static final String Synthetic = "Synthetic";
++
++ // JSR 277/294
++ public static final String Module = "Module";
++ public static final String ModuleExportTable = "ModuleExportTable";
++ public static final String ModuleMemberTable = "ModuleMemberTable";
++
++ public static class Factory {
++ public Factory() {
++ // defer init of standardAttributeClasses until after options set up
++ }
++
++ public void setCompat(boolean compat) {
++ this.compat = compat;
++ }
++
++ public void setJSR277(boolean jsr277) {
++ this.jsr277 = jsr277;
++ }
++
++ public Attribute createAttribute(ClassReader cr, int name_index, byte[] data)
++ throws IOException {
++ if (standardAttributes == null)
++ init();
++
++ ConstantPool cp = cr.getConstantPool();
++ try {
++ String name = cp.getUTF8Value(name_index);
++ Class<? extends Attribute> attrClass = standardAttributes.get(name);
++ if (attrClass != null) {
++ try {
++ Class<?>[] constrArgTypes = {ClassReader.class, int.class, int.class};
++ Constructor<? extends Attribute> constr = attrClass.getDeclaredConstructor(constrArgTypes);
++ return constr.newInstance(new Object[] { cr, name_index, data.length });
++ } catch (Throwable t) {
++ // fall through and use DefaultAttribute
++ // t.printStackTrace();
++ }
++ }
++ } catch (ConstantPoolException e) {
++ // fall through and use DefaultAttribute
++ }
++ return new DefaultAttribute(cr, name_index, data);
++ }
++
++ protected void init() {
++ standardAttributes = new HashMap<String,Class<? extends Attribute>>();
++ standardAttributes.put(AnnotationDefault, AnnotationDefault_attribute.class);
++ standardAttributes.put(CharacterRangeTable, CharacterRangeTable_attribute.class);
++ standardAttributes.put(Code, Code_attribute.class);
++ standardAttributes.put(ConstantValue, ConstantValue_attribute.class);
++ standardAttributes.put(Deprecated, Deprecated_attribute.class);
++ standardAttributes.put(EnclosingMethod, EnclosingMethod_attribute.class);
++ standardAttributes.put(Exceptions, Exceptions_attribute.class);
++ standardAttributes.put(InnerClasses, InnerClasses_attribute.class);
++ standardAttributes.put(LineNumberTable, LineNumberTable_attribute.class);
++ standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class);
++ standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class);
++
++ if (jsr277) {
++ standardAttributes.put(Module, Module_attribute.class);
++ standardAttributes.put(ModuleExportTable, ModuleExportTable_attribute.class);
++ standardAttributes.put(ModuleMemberTable, ModuleMemberTable_attribute.class);
++ }
++
++ if (!compat) { // old javap does not recognize recent attributes
++ standardAttributes.put(CompilationID, CompilationID_attribute.class);
++ standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
++ standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
++ standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
++ standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class);
++ standardAttributes.put(Signature, Signature_attribute.class);
++ standardAttributes.put(SourceID, SourceID_attribute.class);
++ }
++
++ standardAttributes.put(SourceDebugExtension, SourceDebugExtension_attribute.class);
++ standardAttributes.put(SourceFile, SourceFile_attribute.class);
++ standardAttributes.put(StackMap, StackMap_attribute.class);
++ standardAttributes.put(StackMapTable, StackMapTable_attribute.class);
++ standardAttributes.put(Synthetic, Synthetic_attribute.class);
++ }
++
++ private Map<String,Class<? extends Attribute>> standardAttributes;
++ private boolean compat; // don't support recent attrs in compatibility mode
++ private boolean jsr277; // support new jsr277 attrs
++ }
++
++ public static Attribute read(ClassReader cr) throws IOException {
++ return cr.readAttribute();
++ }
++
++ protected Attribute(int name_index, int length) {
++ attribute_name_index = name_index;
++ attribute_length = length;
++ }
++
++ public String getName(ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(attribute_name_index);
++ }
++
++ public abstract <R,D> R accept(Attribute.Visitor<R,D> visitor, D data);
++
++ public final int attribute_name_index;
++ public final int attribute_length;
++
++
++ public interface Visitor<R,P> {
++ R visitDefault(DefaultAttribute attr, P p);
++ R visitAnnotationDefault(AnnotationDefault_attribute attr, P p);
++ R visitCharacterRangeTable(CharacterRangeTable_attribute attr, P p);
++ R visitCode(Code_attribute attr, P p);
++ R visitCompilationID(CompilationID_attribute attr, P p);
++ R visitConstantValue(ConstantValue_attribute attr, P p);
++ R visitDeprecated(Deprecated_attribute attr, P p);
++ R visitEnclosingMethod(EnclosingMethod_attribute attr, P p);
++ R visitExceptions(Exceptions_attribute attr, P p);
++ R visitInnerClasses(InnerClasses_attribute attr, P p);
++ R visitLineNumberTable(LineNumberTable_attribute attr, P p);
++ R visitLocalVariableTable(LocalVariableTable_attribute attr, P p);
++ R visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, P p);
++ R visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, P p);
++ R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p);
++ R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p);
++ R visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, P p);
++ R visitSignature(Signature_attribute attr, P p);
++ R visitSourceDebugExtension(SourceDebugExtension_attribute attr, P p);
++ R visitSourceFile(SourceFile_attribute attr, P p);
++ R visitSourceID(SourceID_attribute attr, P p);
++ R visitStackMap(StackMap_attribute attr, P p);
++ R visitStackMapTable(StackMapTable_attribute attr, P p);
++ R visitSynthetic(Synthetic_attribute attr, P p);
++
++ R visitModule(Module_attribute attr, P p);
++ R visitModuleExportTable(ModuleExportTable_attribute attr, P p);
++ R visitModuleMemberTable(ModuleMemberTable_attribute attr, P p);
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/AttributeException.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/AttributeException.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,40 @@
++/*
++ * 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.
++ */
++
++package com.sun.tools.classfile;
++
++/*
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class AttributeException extends Exception {
++ AttributeException() { }
++
++ AttributeException(String msg) {
++ super(msg);
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Attributes.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Attributes.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,87 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++import java.util.Arrays;
++import java.util.HashMap;
++import java.util.Iterator;
++import java.util.Map;
++
++/*
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Attributes implements Iterable<Attribute> {
++ Attributes(ClassReader cr) throws IOException {
++ map = new HashMap<String,Attribute>();
++ int attrs_count = cr.readUnsignedShort();
++ attrs = new Attribute[attrs_count];
++ for (int i = 0; i < attrs_count; i++) {
++ Attribute attr = Attribute.read(cr);
++ attrs[i] = attr;
++ try {
++ map.put(attr.getName(cr.getConstantPool()), attr);
++ } catch (ConstantPoolException e) {
++ // don't enter invalid names in map
++ }
++ }
++ }
++
++ public Attributes(ConstantPool constant_pool, Attribute[] attrs) {
++ this.attrs = attrs;
++ map = new HashMap<String,Attribute>();
++ for (int i = 0; i < attrs.length; i++) {
++ Attribute attr = attrs[i];
++ try {
++ map.put(attr.getName(constant_pool), attr);
++ } catch (ConstantPoolException e) {
++ // don't enter invalid names in map
++ }
++ }
++ }
++
++ public Iterator<Attribute> iterator() {
++ return Arrays.asList(attrs).iterator();
++ }
++
++ public Attribute get(int index) {
++ return attrs[index];
++ }
++
++ public Attribute get(String name) {
++ return map.get(name);
++ }
++
++ public int size() {
++ return attrs.length;
++ }
++
++ public final Attribute[] attrs;
++ public final Map<String, Attribute> map;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/CharacterRangeTable_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/CharacterRangeTable_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,90 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class CharacterRangeTable_attribute extends Attribute {
++ public static final int CRT_STATEMENT = 0x0001;
++ public static final int CRT_BLOCK = 0x0002;
++ public static final int CRT_ASSIGNMENT = 0x0004;
++ public static final int CRT_FLOW_CONTROLLER = 0x0008;
++ public static final int CRT_FLOW_TARGET = 0x0010;
++ public static final int CRT_INVOKE = 0x0020;
++ public static final int CRT_CREATE = 0x0040;
++ public static final int CRT_BRANCH_TRUE = 0x0080;
++ public static final int CRT_BRANCH_FALSE = 0x0100;
++
++ CharacterRangeTable_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ int character_range_table_length = cr.readUnsignedShort();
++ character_range_table = new Entry[character_range_table_length];
++ for (int i = 0; i < character_range_table_length; i++)
++ character_range_table[i] = new Entry(cr);
++ }
++
++ public CharacterRangeTable_attribute(ConstantPool constant_pool, Entry[] character_range_table)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.CharacterRangeTable), character_range_table);
++ }
++
++ public CharacterRangeTable_attribute(int name_index, Entry[] character_range_table) {
++ super(name_index, character_range_table.length * Entry.length());
++ this.character_range_table = character_range_table;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitCharacterRangeTable(this, data);
++ }
++
++ public final Entry[] character_range_table;
++
++ public static class Entry {
++ Entry(ClassReader cr) throws IOException {
++ start_pc = cr.readUnsignedShort();
++ end_pc = cr.readUnsignedShort();
++ character_range_start = cr.readInt();
++ character_range_end = cr.readInt();
++ flags = cr.readUnsignedShort();
++ }
++
++ public static int length() {
++ return 14;
++ }
++
++ public final int start_pc;
++ public final int end_pc;
++ public final int character_range_start;
++ public final int character_range_end;
++ public final int flags;
++ };
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/ClassFile.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/ClassFile.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,153 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.File;
++import java.io.FileInputStream;
++import java.io.IOException;
++import java.io.InputStream;
++
++import static com.sun.tools.classfile.AccessFlags.*;
++
++/**
++ * See JVMS3, section 4.2.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ClassFile {
++ public static ClassFile read(File file)
++ throws IOException, ConstantPoolException {
++ return read(file, new Attribute.Factory());
++ }
++
++ public static ClassFile read(File file, Attribute.Factory attributeFactory)
++ throws IOException, ConstantPoolException {
++ FileInputStream in = new FileInputStream(file);
++ try {
++ return new ClassFile(in, attributeFactory);
++ } finally {
++ try {
++ in.close();
++ } catch (IOException e) {
++ // ignore
++ }
++ }
++ }
++
++ public static ClassFile read(InputStream in)
++ throws IOException, ConstantPoolException {
++ return new ClassFile(in, new Attribute.Factory());
++ }
++
++ public static ClassFile read(InputStream in, Attribute.Factory attributeFactory)
++ throws IOException, ConstantPoolException {
++ return new ClassFile(in, attributeFactory);
++ }
++
++ ClassFile(InputStream in, Attribute.Factory attributeFactory) throws IOException, ConstantPoolException {
++ ClassReader cr = new ClassReader(this, in, attributeFactory);
++ magic = cr.readInt();
++ minor_version = cr.readUnsignedShort();
++ major_version = cr.readUnsignedShort();
++ constant_pool = new ConstantPool(cr);
++ access_flags = new AccessFlags(cr);
++ this_class = cr.readUnsignedShort();
++ super_class = cr.readUnsignedShort();
++
++ int interfaces_count = cr.readUnsignedShort();
++ interfaces = new int[interfaces_count];
++ for (int i = 0; i < interfaces_count; i++)
++ interfaces[i] = cr.readUnsignedShort();
++
++ int fields_count = cr.readUnsignedShort();
++ fields = new Field[fields_count];
++ for (int i = 0; i < fields_count; i++)
++ fields[i] = new Field(cr);
++
++ int methods_count = cr.readUnsignedShort();
++ methods = new Method[methods_count];
++ for (int i = 0; i < methods_count; i++)
++ methods[i] = new Method(cr);
++
++ attributes = new Attributes(cr);
++ }
++
++ public ClassFile(int magic, int minor_version, int major_version,
++ ConstantPool constant_pool, AccessFlags access_flags,
++ int this_class, int super_class, int[] interfaces,
++ Field[] fields, Method[] methods, Attributes attributes) {
++ this.magic = magic;
++ this.minor_version = minor_version;
++ this.major_version = major_version;
++ this.constant_pool = constant_pool;
++ this.access_flags = access_flags;
++ this.this_class = this_class;
++ this.super_class = super_class;
++ this.interfaces = interfaces;
++ this.fields = fields;
++ this.methods = methods;
++ this.attributes = attributes;
++ }
++
++ public String getName() throws ConstantPoolException {
++ return constant_pool.getClassInfo(this_class).getName();
++ }
++
++ public String getSuperclassName() throws ConstantPoolException {
++ return constant_pool.getClassInfo(super_class).getName();
++ }
++
++ public String getInterfaceName(int i) throws ConstantPoolException {
++ return constant_pool.getClassInfo(interfaces[i]).getName();
++ }
++
++ public Attribute getAttribute(String name) {
++ return attributes.get(name);
++ }
++
++ public boolean isClass() {
++ return !isInterface();
++ }
++
++ public boolean isInterface() {
++ return access_flags.is(ACC_INTERFACE);
++ }
++
++ public final int magic;
++ public final int minor_version;
++ public final int major_version;
++ public final ConstantPool constant_pool;
++ public final AccessFlags access_flags;
++ public final int this_class;
++ public final int super_class;
++ public final int[] interfaces;
++ public final Field[] fields;
++ public final Method[] methods;
++ public final Attributes attributes;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/ClassReader.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/ClassReader.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,109 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.BufferedInputStream;
++import java.io.ByteArrayInputStream;
++import java.io.DataInputStream;
++import java.io.IOException;
++import java.io.InputStream;
++
++/**
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ClassReader {
++ ClassReader(ClassFile classFile, InputStream in, Attribute.Factory attributeFactory) throws IOException {
++ // null checks
++ classFile.getClass();
++ attributeFactory.getClass();
++
++ this.classFile = classFile;
++ this.in = new DataInputStream(new BufferedInputStream(in));
++ this.attributeFactory = attributeFactory;
++ }
++
++ ClassFile getClassFile() {
++ return classFile;
++ }
++
++ ConstantPool getConstantPool() {
++ return classFile.constant_pool;
++ }
++
++ public Attribute readAttribute() throws IOException {
++ int name_index = readUnsignedShort();
++ int length = readInt();
++ byte[] data = new byte[length];
++ readFully(data);
++
++ DataInputStream prev = in;
++ in = new DataInputStream(new ByteArrayInputStream(data));
++ try {
++ return attributeFactory.createAttribute(this, name_index, data);
++ } finally {
++ in = prev;
++ }
++ }
++
++ public void readFully(byte[] b) throws IOException {
++ in.readFully(b);
++ }
++
++ public int readUnsignedByte() throws IOException {
++ return in.readUnsignedByte();
++ }
++
++ public int readUnsignedShort() throws IOException {
++ return in.readUnsignedShort();
++ }
++
++ public int readInt() throws IOException {
++ return in.readInt();
++ }
++
++ public long readLong() throws IOException {
++ return in.readLong();
++ }
++
++ public float readFloat() throws IOException {
++ return in.readFloat();
++ }
++
++ public double readDouble() throws IOException {
++ return in.readDouble();
++ }
++
++ public String readUTF() throws IOException {
++ return in.readUTF();
++ }
++
++ private DataInputStream in;
++ private ClassFile classFile;
++ private Attribute.Factory attributeFactory;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/ClassTranslator.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/ClassTranslator.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,368 @@
++/*
++ * 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.
++ */
++
++package com.sun.tools.classfile;
++
++import com.sun.tools.classfile.ConstantPool.CONSTANT_Class_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_Double_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_Fieldref_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_Float_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_Integer_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_InterfaceMethodref_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_Long_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_Methodref_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_NameAndType_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_String_info;
++import com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8_info;
++import com.sun.tools.classfile.ConstantPool.CPInfo;
++import java.util.Map;
++
++/**
++ * Rewrites a class file using a map of translations.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ClassTranslator
++ implements ConstantPool.Visitor<ConstantPool.CPInfo,Map<Object,Object>> {
++ /**
++ * Create a new ClassFile from {@code cf}, such that for all entries
++ * {@code k&nbsp;-\&gt;&nbsp;v} in {@code translations},
++ * each occurrence of {@code k} in {@code cf} will be replaced by {@code v}.
++ * in
++ * @param cf the class file to be processed
++ * @param translations the set of translations to be applied
++ * @return a copy of {@code} with the values in {@code translations} substituted
++ */
++ public ClassFile translate(ClassFile cf, Map<Object,Object> translations) {
++ ClassFile cf2 = (ClassFile) translations.get(cf);
++ if (cf2 == null) {
++ ConstantPool constant_pool2 = translate(cf.constant_pool, translations);
++ Field[] fields2 = translate(cf.fields, cf.constant_pool, translations);
++ Method[] methods2 = translateMethods(cf.methods, cf.constant_pool, translations);
++ Attributes attributes2 = translateAttributes(cf.attributes, cf.constant_pool,
++ translations);
++
++ if (constant_pool2 == cf.constant_pool &&
++ fields2 == cf.fields &&
++ methods2 == cf.methods &&
++ attributes2 == cf.attributes)
++ cf2 = cf;
++ else
++ cf2 = new ClassFile(
++ cf.magic,
++ cf.minor_version,
++ cf.major_version,
++ constant_pool2,
++ cf.access_flags,
++ cf.this_class,
++ cf.super_class,
++ cf.interfaces,
++ fields2,
++ methods2,
++ attributes2);
++ translations.put(cf, cf2);
++ }
++ return cf2;
++ }
++
++ ConstantPool translate(ConstantPool cp, Map<Object,Object> translations) {
++ ConstantPool cp2 = (ConstantPool) translations.get(cp);
++ if (cp2 == null) {
++ ConstantPool.CPInfo[] pool2 = new ConstantPool.CPInfo[cp.size()];
++ boolean eq = true;
++ for (int i = 0; i < cp.size(); i++) {
++ ConstantPool.CPInfo cpInfo;
++ try {
++ cpInfo = cp.get(i);
++ } catch (ConstantPool.InvalidIndex e) {
++ throw new IllegalStateException(e);
++ }
++ ConstantPool.CPInfo cpInfo2 = translate(cpInfo, translations);
++ eq &= (cpInfo == cpInfo2);
++ pool2[i] = cpInfo2;
++ if (cpInfo.getTag() != cpInfo2.getTag())
++ throw new IllegalStateException();
++ switch (cpInfo.getTag()) {
++ case ConstantPool.CONSTANT_Double:
++ case ConstantPool.CONSTANT_Long:
++ i += 1;
++ }
++ }
++
++ if (eq)
++ cp2 = cp;
++ else
++ cp2 = new ConstantPool(pool2);
++
++ translations.put(cp, cp2);
++ }
++ return cp2;
++ }
++
++ ConstantPool.CPInfo translate(ConstantPool.CPInfo cpInfo, Map<Object,Object> translations) {
++ ConstantPool.CPInfo cpInfo2 = (ConstantPool.CPInfo) translations.get(cpInfo);
++ if (cpInfo2 == null) {
++ cpInfo2 = cpInfo.accept(this, translations);
++ translations.put(cpInfo, cpInfo2);
++ }
++ return cpInfo2;
++ }
++
++ Field[] translate(Field[] fields, ConstantPool constant_pool, Map<Object,Object> translations) {
++ Field[] fields2 = (Field[]) translations.get(fields);
++ if (fields2 == null) {
++ fields2 = new Field[fields.length];
++ for (int i = 0; i < fields.length; i++)
++ fields2[i] = translate(fields[i], constant_pool, translations);
++ if (equal(fields, fields2))
++ fields2 = fields;
++ translations.put(fields, fields2);
++ }
++ return fields2;
++ }
++
++ Field translate(Field field, ConstantPool constant_pool, Map<Object,Object> translations) {
++ Field field2 = (Field) translations.get(field);
++ if (field2 == null) {
++ Attributes attributes2 = translateAttributes(field.attributes, constant_pool,
++ translations);
++
++ if (attributes2 == field.attributes)
++ field2 = field;
++ else
++ field2 = new Field(
++ field.access_flags,
++ field.name_index,
++ field.descriptor,
++ attributes2);
++ translations.put(field, field2);
++ }
++ return field2;
++ }
++
++ Method[] translateMethods(Method[] methods, ConstantPool constant_pool, Map<Object,Object> translations) {
++ Method[] methods2 = (Method[]) translations.get(methods);
++ if (methods2 == null) {
++ methods2 = new Method[methods.length];
++ for (int i = 0; i < methods.length; i++)
++ methods2[i] = translate(methods[i], constant_pool, translations);
++ if (equal(methods, methods2))
++ methods2 = methods;
++ translations.put(methods, methods2);
++ }
++ return methods2;
++ }
++
++ Method translate(Method method, ConstantPool constant_pool, Map<Object,Object> translations) {
++ Method method2 = (Method) translations.get(method);
++ if (method2 == null) {
++ Attributes attributes2 = translateAttributes(method.attributes, constant_pool,
++ translations);
++
++ if (attributes2 == method.attributes)
++ method2 = method;
++ else
++ method2 = new Method(
++ method.access_flags,
++ method.name_index,
++ method.descriptor,
++ attributes2);
++ translations.put(method, method2);
++ }
++ return method2;
++ }
++
++ Attributes translateAttributes(Attributes attributes,
++ ConstantPool constant_pool, Map<Object,Object> translations) {
++ Attributes attributes2 = (Attributes) translations.get(attributes);
++ if (attributes2 == null) {
++ Attribute[] attrArray2 = new Attribute[attributes.size()];
++ ConstantPool constant_pool2 = translate(constant_pool, translations);
++ boolean attrsEqual = true;
++ for (int i = 0; i < attributes.size(); i++) {
++ Attribute attr = attributes.get(i);
++ Attribute attr2 = translate(attr, translations);
++ if (attr2 != attr)
++ attrsEqual = false;
++ attrArray2[i] = attr2;
++ }
++ if ((constant_pool2 == constant_pool) && attrsEqual)
++ attributes2 = attributes;
++ else
++ attributes2 = new Attributes(constant_pool2, attrArray2);
++ translations.put(attributes, attributes2);
++ }
++ return attributes2;
++ }
++
++ Attribute translate(Attribute attribute, Map<Object,Object> translations) {
++ Attribute attribute2 = (Attribute) translations.get(attribute);
++ if (attribute2 == null) {
++ attribute2 = attribute; // don't support translation within attributes yet
++ // (what about Code attribute)
++ translations.put(attribute, attribute2);
++ }
++ return attribute2;
++ }
++
++ private static <T> boolean equal(T[] a1, T[] a2) {
++ if (a1 == null || a2 == null)
++ return (a1 == a2);
++ if (a1.length != a2.length)
++ return false;
++ for (int i = 0; i < a1.length; i++) {
++ if (a1[i] != a2[i])
++ return false;
++ }
++ return true;
++ }
++
++ public CPInfo visitClass(CONSTANT_Class_info info, Map<Object, Object> translations) {
++ CONSTANT_Class_info info2 = (CONSTANT_Class_info) translations.get(info);
++ if (info2 == null) {
++ ConstantPool cp2 = translate(info.cp, translations);
++ if (cp2 == info.cp)
++ info2 = info;
++ else
++ info2 = new CONSTANT_Class_info(cp2, info.name_index);
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitDouble(CONSTANT_Double_info info, Map<Object, Object> translations) {
++ CONSTANT_Double_info info2 = (CONSTANT_Double_info) translations.get(info);
++ if (info2 == null) {
++ info2 = info;
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitFieldref(CONSTANT_Fieldref_info info, Map<Object, Object> translations) {
++ CONSTANT_Fieldref_info info2 = (CONSTANT_Fieldref_info) translations.get(info);
++ if (info2 == null) {
++ ConstantPool cp2 = translate(info.cp, translations);
++ if (cp2 == info.cp)
++ info2 = info;
++ else
++ info2 = new CONSTANT_Fieldref_info(cp2, info.class_index, info.name_and_type_index);
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitFloat(CONSTANT_Float_info info, Map<Object, Object> translations) {
++ CONSTANT_Float_info info2 = (CONSTANT_Float_info) translations.get(info);
++ if (info2 == null) {
++ info2 = info;
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitInteger(CONSTANT_Integer_info info, Map<Object, Object> translations) {
++ CONSTANT_Integer_info info2 = (CONSTANT_Integer_info) translations.get(info);
++ if (info2 == null) {
++ info2 = info;
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Map<Object, Object> translations) {
++ CONSTANT_InterfaceMethodref_info info2 = (CONSTANT_InterfaceMethodref_info) translations.get(info);
++ if (info2 == null) {
++ ConstantPool cp2 = translate(info.cp, translations);
++ if (cp2 == info.cp)
++ info2 = info;
++ else
++ info2 = new CONSTANT_InterfaceMethodref_info(cp2, info.class_index, info.name_and_type_index);
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitLong(CONSTANT_Long_info info, Map<Object, Object> translations) {
++ CONSTANT_Long_info info2 = (CONSTANT_Long_info) translations.get(info);
++ if (info2 == null) {
++ info2 = info;
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitNameAndType(CONSTANT_NameAndType_info info, Map<Object, Object> translations) {
++ CONSTANT_NameAndType_info info2 = (CONSTANT_NameAndType_info) translations.get(info);
++ if (info2 == null) {
++ ConstantPool cp2 = translate(info.cp, translations);
++ if (cp2 == info.cp)
++ info2 = info;
++ else
++ info2 = new CONSTANT_NameAndType_info(cp2, info.name_index, info.type_index);
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitMethodref(CONSTANT_Methodref_info info, Map<Object, Object> translations) {
++ CONSTANT_Methodref_info info2 = (CONSTANT_Methodref_info) translations.get(info);
++ if (info2 == null) {
++ ConstantPool cp2 = translate(info.cp, translations);
++ if (cp2 == info.cp)
++ info2 = info;
++ else
++ info2 = new CONSTANT_Methodref_info(cp2, info.class_index, info.name_and_type_index);
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitString(CONSTANT_String_info info, Map<Object, Object> translations) {
++ CONSTANT_String_info info2 = (CONSTANT_String_info) translations.get(info);
++ if (info2 == null) {
++ ConstantPool cp2 = translate(info.cp, translations);
++ if (cp2 == info.cp)
++ info2 = info;
++ else
++ info2 = new CONSTANT_String_info(cp2, info.string_index);
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++ public CPInfo visitUtf8(CONSTANT_Utf8_info info, Map<Object, Object> translations) {
++ CONSTANT_Utf8_info info2 = (CONSTANT_Utf8_info) translations.get(info);
++ if (info2 == null) {
++ info2 = info;
++ translations.put(info, info2);
++ }
++ return info;
++ }
++
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/ClassWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,689 @@
++/*
++ * 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.
++ */
++
++package com.sun.tools.classfile;
++
++import java.io.ByteArrayOutputStream;
++import java.io.DataOutputStream;
++import java.io.File;
++import java.io.FileOutputStream;
++import java.io.IOException;
++import java.io.OutputStream;
++
++import static com.sun.tools.classfile.Annotation.*;
++import static com.sun.tools.classfile.ConstantPool.*;
++import static com.sun.tools.classfile.StackMapTable_attribute.*;
++import static com.sun.tools.classfile.StackMapTable_attribute.verification_type_info.*;
++
++/**
++ * Write a ClassFile data structure to a file or stream.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ClassWriter {
++ public ClassWriter() {
++ attributeWriter = new AttributeWriter();
++ constantPoolWriter = new ConstantPoolWriter();
++ out = new ClassOutputStream();
++ }
++
++ /**
++ * Write a ClassFile data structure to a file.
++ */
++ public void write(ClassFile classFile, File f) throws IOException {
++ FileOutputStream f_out = new FileOutputStream(f);
++ try {
++ write(classFile, f_out);
++ } finally {
++ f_out.close();
++ }
++ }
++
++ /**
++ * Write a ClassFile data structure to a stream.
++ */
++ public void write(ClassFile classFile, OutputStream s) throws IOException {
++ this.classFile = classFile;
++ out.reset();
++ write();
++ out.writeTo(s);
++ }
++
++ protected void write() throws IOException {
++ writeHeader();
++ writeConstantPool();
++ writeAccessFlags(classFile.access_flags);
++ writeClassInfo();
++ writeFields();
++ writeMethods();
++ writeAttributes(classFile.attributes);
++ }
++
++ protected void writeHeader() {
++ out.writeInt(classFile.magic);
++ out.writeShort(classFile.minor_version);
++ out.writeShort(classFile.major_version);
++ }
++
++ protected void writeAccessFlags(AccessFlags flags) {
++ out.writeShort(flags.flags);
++ }
++
++ protected void writeAttributes(Attributes attributes) {
++ int size = attributes.size();
++ out.writeShort(size);
++ for (Attribute attr: attributes)
++ attributeWriter.write(attr, out);
++ }
++
++ protected void writeClassInfo() {
++ out.writeShort(classFile.this_class);
++ out.writeShort(classFile.super_class);
++ int[] interfaces = classFile.interfaces;
++ out.writeShort(interfaces.length);
++ for (int i: interfaces)
++ out.writeShort(i);
++ }
++
++ protected void writeDescriptor(Descriptor d) {
++ out.writeShort(d.index);
++ }
++
++ protected void writeConstantPool() {
++ ConstantPool pool = classFile.constant_pool;
++ int size = pool.size();
++ out.writeShort(size);
++ try {
++ for (int i = 1; i < size; ) {
++ i += constantPoolWriter.write(pool.get(i), out);
++ }
++ } catch (ConstantPoolException e) {
++ throw new Error(e); // ??
++ }
++ }
++
++ protected void writeFields() throws IOException {
++ Field[] fields = classFile.fields;
++ out.writeShort(fields.length);
++ for (Field f: fields)
++ writeField(f);
++ }
++
++ protected void writeField(Field f) throws IOException {
++ writeAccessFlags(f.access_flags);
++ out.writeShort(f.name_index);
++ writeDescriptor(f.descriptor);
++ writeAttributes(f.attributes);
++ }
++
++ protected void writeMethods() throws IOException {
++ Method[] methods = classFile.methods;
++ out.writeShort(methods.length);
++ for (Method m: methods) {
++ writeMethod(m);
++ }
++ }
++
++ protected void writeMethod(Method m) throws IOException {
++ writeAccessFlags(m.access_flags);
++ out.writeShort(m.name_index);
++ writeDescriptor(m.descriptor);
++ writeAttributes(m.attributes);
++ }
++
++ protected ClassFile classFile;
++ protected ClassOutputStream out;
++ protected AttributeWriter attributeWriter;
++ protected ConstantPoolWriter constantPoolWriter;
++
++ /**
++ * Subtype of ByteArrayOutputStream with the convenience methods of
++ * a DataOutputStream. Since ByteArrayOutputStream does not throw
++ * IOException, there are no exceptions from the additional
++ * convenience methods either,
++ */
++ protected static class ClassOutputStream extends ByteArrayOutputStream {
++ public ClassOutputStream() {
++ d = new DataOutputStream(this);
++ }
++
++ public void writeByte(int value) {
++ try {
++ d.writeByte(value);
++ } catch (IOException ignore) {
++ }
++ }
++
++ public void writeShort(int value) {
++ try {
++ d.writeShort(value);
++ } catch (IOException ignore) {
++ }
++ }
++
++ public void writeInt(int value) {
++ try {
++ d.writeInt(value);
++ } catch (IOException ignore) {
++ }
++ }
++
++ public void writeLong(long value) {
++ try {
++ d.writeLong(value);
++ } catch (IOException ignore) {
++ }
++ }
++
++ public void writeFloat(float value) {
++ try {
++ d.writeFloat(value);
++ } catch (IOException ignore) {
++ }
++ }
++
++ public void writeDouble(double value) {
++ try {
++ d.writeDouble(value);
++ } catch (IOException ignore) {
++ }
++ }
++
++ public void writeUTF(String value) {
++ try {
++ d.writeUTF(value);
++ } catch (IOException ignore) {
++ }
++ }
++
++ public void writeTo(ClassOutputStream s) {
++ try {
++ super.writeTo(s);
++ } catch (IOException ignore) {
++ }
++ }
++
++ private DataOutputStream d;
++ }
++
++ /**
++ * Writer for the entries in the constant pool.
++ */
++ protected static class ConstantPoolWriter
++ implements ConstantPool.Visitor<Integer,ClassOutputStream> {
++ protected int write(CPInfo info, ClassOutputStream out) {
++ out.writeByte(info.getTag());
++ return info.accept(this, out);
++ }
++
++ public Integer visitClass(CONSTANT_Class_info info, ClassOutputStream out) {
++ out.writeShort(info.name_index);
++ return 1;
++ }
++
++ public Integer visitDouble(CONSTANT_Double_info info, ClassOutputStream out) {
++ out.writeDouble(info.value);
++ return 2;
++ }
++
++ public Integer visitFieldref(CONSTANT_Fieldref_info info, ClassOutputStream out) {
++ writeRef(info, out);
++ return 1;
++ }
++
++ public Integer visitFloat(CONSTANT_Float_info info, ClassOutputStream out) {
++ out.writeFloat(info.value);
++ return 1;
++ }
++
++ public Integer visitInteger(CONSTANT_Integer_info info, ClassOutputStream out) {
++ out.writeInt(info.value);
++ return 1;
++ }
++
++ public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, ClassOutputStream out) {
++ writeRef(info, out);
++ return 1;
++ }
++
++ public Integer visitLong(CONSTANT_Long_info info, ClassOutputStream out) {
++ out.writeLong(info.value);
++ return 2;
++ }
++
++ public Integer visitNameAndType(CONSTANT_NameAndType_info info, ClassOutputStream out) {
++ out.writeShort(info.name_index);
++ out.writeShort(info.type_index);
++ return 1;
++ }
++
++ public Integer visitMethodref(CONSTANT_Methodref_info info, ClassOutputStream out) {
++ return writeRef(info, out);
++ }
++
++ public Integer visitString(CONSTANT_String_info info, ClassOutputStream out) {
++ out.writeShort(info.string_index);
++ return 1;
++ }
++
++ public Integer visitUtf8(CONSTANT_Utf8_info info, ClassOutputStream out) {
++ out.writeUTF(info.value);
++ return 1;
++ }
++
++ protected Integer writeRef(CPRefInfo info, ClassOutputStream out) {
++ out.writeShort(info.class_index);
++ out.writeShort(info.name_and_type_index);
++ return 1;
++ }
++ }
++
++ /**
++ * Writer for the different types of attribute.
++ */
++ protected static class AttributeWriter implements Attribute.Visitor<Void,ClassOutputStream> {
++ public void write(Attributes attributes, ClassOutputStream out) {
++ int size = attributes.size();
++ out.writeShort(size);
++ for (Attribute a: attributes)
++ write(a, out);
++ }
++
++ // Note: due to the use of shared resources, this method is not reentrant.
++ public void write(Attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.attribute_name_index);
++ sharedOut.reset();
++ attr.accept(this, sharedOut);
++ out.writeInt(sharedOut.size());
++ sharedOut.writeTo(out);
++ }
++
++ protected ClassOutputStream sharedOut = new ClassOutputStream();
++ protected AnnotationWriter annotationWriter = new AnnotationWriter();
++
++ public Void visitDefault(DefaultAttribute attr, ClassOutputStream out) {
++ out.write(attr.info, 0, attr.info.length);
++ return null;
++ }
++
++ public Void visitAnnotationDefault(AnnotationDefault_attribute attr, ClassOutputStream out) {
++ annotationWriter.write(attr.default_value, out);
++ return null;
++ }
++
++ public Void visitCharacterRangeTable(CharacterRangeTable_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.character_range_table.length);
++ for (CharacterRangeTable_attribute.Entry e: attr.character_range_table)
++ writeCharacterRangeTableEntry(e, out);
++ return null;
++ }
++
++ protected void writeCharacterRangeTableEntry(CharacterRangeTable_attribute.Entry entry, ClassOutputStream out) {
++ out.writeShort(entry.start_pc);
++ out.writeShort(entry.end_pc);
++ out.writeInt(entry.character_range_start);
++ out.writeInt(entry.character_range_end);
++ out.writeShort(entry.flags);
++ }
++
++ public Void visitCode(Code_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.max_stack);
++ out.writeShort(attr.max_locals);
++ out.writeInt(attr.code.length);
++ out.write(attr.code, 0, attr.code.length);
++ out.writeShort(attr.exception_table.length);
++ for (Code_attribute.Exception_data e: attr.exception_table)
++ writeExceptionTableEntry(e, out);
++ new AttributeWriter().write(attr.attributes, out);
++ return null;
++ }
++
++ protected void writeExceptionTableEntry(Code_attribute.Exception_data exception_data, ClassOutputStream out) {
++ out.writeShort(exception_data.start_pc);
++ out.writeShort(exception_data.end_pc);
++ out.writeShort(exception_data.handler_pc);
++ out.writeShort(exception_data.catch_type);
++ }
++
++ public Void visitCompilationID(CompilationID_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.compilationID_index);
++ return null;
++ }
++
++ public Void visitConstantValue(ConstantValue_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.constantvalue_index);
++ return null;
++ }
++
++ public Void visitDeprecated(Deprecated_attribute attr, ClassOutputStream out) {
++ return null;
++ }
++
++ public Void visitEnclosingMethod(EnclosingMethod_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.class_index);
++ out.writeShort(attr.method_index);
++ return null;
++ }
++
++ public Void visitExceptions(Exceptions_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.exception_index_table.length);
++ for (int i: attr.exception_index_table)
++ out.writeShort(i);
++ return null;
++ }
++
++ public Void visitInnerClasses(InnerClasses_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.classes.length);
++ for (InnerClasses_attribute.Info info: attr.classes)
++ writeInnerClassesInfo(info, out);
++ return null;
++ }
++
++ protected void writeInnerClassesInfo(InnerClasses_attribute.Info info, ClassOutputStream out) {
++ out.writeShort(info.inner_class_info_index);
++ out.writeShort(info.outer_class_info_index);
++ out.writeShort(info.inner_name_index);
++ writeAccessFlags(info.inner_class_access_flags, out);
++ }
++
++ public Void visitLineNumberTable(LineNumberTable_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.line_number_table.length);
++ for (LineNumberTable_attribute.Entry e: attr.line_number_table)
++ writeLineNumberTableEntry(e, out);
++ return null;
++ }
++
++ protected void writeLineNumberTableEntry(LineNumberTable_attribute.Entry entry, ClassOutputStream out) {
++ out.writeShort(entry.start_pc);
++ out.writeShort(entry.line_number);
++ }
++
++ public Void visitLocalVariableTable(LocalVariableTable_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.local_variable_table.length);
++ for (LocalVariableTable_attribute.Entry e: attr.local_variable_table)
++ writeLocalVariableTableEntry(e, out);
++ return null;
++ }
++
++ protected void writeLocalVariableTableEntry(LocalVariableTable_attribute.Entry entry, ClassOutputStream out) {
++ out.writeShort(entry.start_pc);
++ out.writeShort(entry.length);
++ out.writeShort(entry.name_index);
++ out.writeShort(entry.descriptor_index);
++ out.writeShort(entry.index);
++ }
++
++ public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, ClassOutputStream out) {
++ out.writeByte(attr.local_variable_table.length);
++ for (LocalVariableTypeTable_attribute.Entry e: attr.local_variable_table)
++ writeLocalVariableTypeTableEntry(e, out);
++ return null;
++ }
++
++ protected void writeLocalVariableTypeTableEntry(LocalVariableTypeTable_attribute.Entry entry, ClassOutputStream out) {
++ out.writeShort(entry.start_pc);
++ out.writeShort(entry.length);
++ out.writeShort(entry.name_index);
++ out.writeShort(entry.signature_index);
++ out.writeShort(entry.index);
++ }
++
++ public Void visitModule(Module_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.module_name);
++ return null;
++ }
++
++ public Void visitModuleExportTable(ModuleExportTable_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.export_type_table.length);
++ for (int i: attr.export_type_table)
++ out.writeShort(i);
++ return null;
++ }
++
++ public Void visitModuleMemberTable(ModuleMemberTable_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.package_member_table.length);
++ for (int i: attr.package_member_table)
++ out.writeShort(i);
++ return null;
++ }
++
++ public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, ClassOutputStream out) {
++ annotationWriter.write(attr.annotations, out);
++ return null;
++ }
++
++ public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, ClassOutputStream out) {
++ annotationWriter.write(attr.annotations, out);
++ return null;
++ }
++
++ public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, ClassOutputStream out) {
++ out.writeByte(attr.parameter_annotations.length);
++ for (Annotation[] annos: attr.parameter_annotations)
++ annotationWriter.write(annos, out);
++ return null;
++ }
++
++ public Void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, ClassOutputStream out) {
++ out.writeByte(attr.parameter_annotations.length);
++ for (Annotation[] annos: attr.parameter_annotations)
++ annotationWriter.write(annos, out);
++ return null;
++ }
++
++ public Void visitSignature(Signature_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.signature_index);
++ return null;
++ }
++
++ public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, ClassOutputStream out) {
++ out.write(attr.debug_extension, 0, attr.debug_extension.length);
++ return null;
++ }
++
++ public Void visitSourceFile(SourceFile_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.sourcefile_index);
++ return null;
++ }
++
++ public Void visitSourceID(SourceID_attribute attr, ClassOutputStream out) {
++ out.writeShort(attr.sourceID_index);
++ return null;
++ }
++
++ public Void visitStackMap(StackMap_attribute attr, ClassOutputStream out) {
++ if (stackMapWriter == null)
++ stackMapWriter = new StackMapTableWriter();
++
++ out.writeShort(attr.entries.length);
++ for (stack_map_frame f: attr.entries)
++ stackMapWriter.write(f, out);
++ return null;
++ }
++
++ public Void visitStackMapTable(StackMapTable_attribute attr, ClassOutputStream out) {
++ if (stackMapWriter == null)
++ stackMapWriter = new StackMapTableWriter();
++
++ out.writeShort(attr.entries.length);
++ for (stack_map_frame f: attr.entries)
++ stackMapWriter.write(f, out);
++ return null;
++ }
++
++ public Void visitSynthetic(Synthetic_attribute attr, ClassOutputStream out) {
++ return null;
++ }
++
++ protected void writeAccessFlags(AccessFlags flags, ClassOutputStream p) {
++ sharedOut.writeShort(flags.flags);
++ }
++
++ protected StackMapTableWriter stackMapWriter;
++ }
++
++ /**
++ * Writer for the frames of StackMap and StackMapTable attributes.
++ */
++ protected static class StackMapTableWriter
++ implements stack_map_frame.Visitor<Void,ClassOutputStream> {
++
++ public void write(stack_map_frame frame, ClassOutputStream out) {
++ out.write(frame.frame_type);
++ frame.accept(this, out);
++ }
++
++ public Void visit_same_frame(same_frame frame, ClassOutputStream p) {
++ return null;
++ }
++
++ public Void visit_same_locals_1_stack_item_frame(same_locals_1_stack_item_frame frame, ClassOutputStream out) {
++ writeVerificationTypeInfo(frame.stack[0], out);
++ return null;
++ }
++
++ public Void visit_same_locals_1_stack_item_frame_extended(same_locals_1_stack_item_frame_extended frame, ClassOutputStream out) {
++ out.writeShort(frame.offset_delta);
++ writeVerificationTypeInfo(frame.stack[0], out);
++ return null;
++ }
++
++ public Void visit_chop_frame(chop_frame frame, ClassOutputStream out) {
++ out.writeShort(frame.offset_delta);
++ return null;
++ }
++
++ public Void visit_same_frame_extended(same_frame_extended frame, ClassOutputStream out) {
++ out.writeShort(frame.offset_delta);
++ return null;
++ }
++
++ public Void visit_append_frame(append_frame frame, ClassOutputStream out) {
++ out.writeShort(frame.offset_delta);
++ for (verification_type_info l: frame.locals)
++ writeVerificationTypeInfo(l, out);
++ return null;
++ }
++
++ public Void visit_full_frame(full_frame frame, ClassOutputStream out) {
++ out.writeShort(frame.offset_delta);
++ out.writeShort(frame.locals.length);
++ for (verification_type_info l: frame.locals)
++ writeVerificationTypeInfo(l, out);
++ out.writeShort(frame.stack.length);
++ for (verification_type_info s: frame.stack)
++ writeVerificationTypeInfo(s, out);
++ return null;
++ }
++
++ protected void writeVerificationTypeInfo(verification_type_info info,
++ ClassOutputStream out) {
++ out.write(info.tag);
++ switch (info.tag) {
++ case ITEM_Top:
++ case ITEM_Integer:
++ case ITEM_Float:
++ case ITEM_Long:
++ case ITEM_Double:
++ case ITEM_Null:
++ case ITEM_UninitializedThis:
++ break;
++
++ case ITEM_Object:
++ Object_variable_info o = (Object_variable_info) info;
++ out.writeShort(o.cpool_index);
++ break;
++
++ case ITEM_Uninitialized:
++ Uninitialized_variable_info u = (Uninitialized_variable_info) info;
++ out.writeShort(u.offset);
++ break;
++
++ default:
++ throw new Error();
++ }
++ }
++ }
++
++ /**
++ * Writer for annotations and the values they contain.
++ */
++ protected static class AnnotationWriter
++ implements Annotation.element_value.Visitor<Void,ClassOutputStream> {
++ public void write(Annotation[] annos, ClassOutputStream out) {
++ out.writeShort(annos.length);
++ for (Annotation anno: annos)
++ write(anno, out);
++ }
++
++ public void write(Annotation anno, ClassOutputStream out) {
++ out.writeShort(anno.type_index);
++ out.writeShort(anno.element_value_pairs.length);
++ for (element_value_pair p: anno.element_value_pairs)
++ write(p, out);
++ }
++
++ public void write(element_value_pair pair, ClassOutputStream out) {
++ out.writeShort(pair.element_name_index);
++ write(pair.value, out);
++ }
++
++ public void write(element_value ev, ClassOutputStream out) {
++ out.writeByte(ev.tag);
++ ev.accept(this, out);
++ }
++
++ public Void visitPrimitive(Primitive_element_value ev, ClassOutputStream out) {
++ out.writeShort(ev.const_value_index);
++ return null;
++ }
++
++ public Void visitEnum(Enum_element_value ev, ClassOutputStream out) {
++ out.writeShort(ev.type_name_index);
++ out.writeShort(ev.const_name_index);
++ return null;
++ }
++
++ public Void visitClass(Class_element_value ev, ClassOutputStream out) {
++ out.writeShort(ev.class_info_index);
++ return null;
++ }
++
++ public Void visitAnnotation(Annotation_element_value ev, ClassOutputStream out) {
++ write(ev.annotation_value, out);
++ return null;
++ }
++
++ public Void visitArray(Array_element_value ev, ClassOutputStream out) {
++ out.writeShort(ev.num_values);
++ for (element_value v: ev.values)
++ write(v, out);
++ return null;
++ }
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Code_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,123 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.3.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Code_attribute extends Attribute {
++ public class InvalidIndex extends AttributeException {
++ InvalidIndex(int index) {
++ this.index = index;
++ }
++
++ @Override
++ public String getMessage() {
++ // i18n
++ return "invalid index " + index + " in Code attribute";
++ }
++
++ public final int index;
++ }
++
++ Code_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, ConstantPoolException {
++ super(name_index, length);
++ max_stack = cr.readUnsignedShort();
++ max_locals = cr.readUnsignedShort();
++ code_length = cr.readInt();
++ code = new byte[code_length];
++ cr.readFully(code);
++ exception_table_langth = cr.readUnsignedShort();
++ exception_table = new Exception_data[exception_table_langth];
++ for (int i = 0; i < exception_table_langth; i++)
++ exception_table[i] = new Exception_data(cr);
++ attributes = new Attributes(cr);
++ }
++
++ public int getByte(int offset) throws InvalidIndex {
++ if (offset < 0 || offset >= code.length)
++ throw new InvalidIndex(offset);
++ return code[offset];
++ }
++
++ public int getUnsignedByte(int offset) throws InvalidIndex {
++ if (offset < 0 || offset >= code.length)
++ throw new InvalidIndex(offset);
++ return code[offset] & 0xff;
++ }
++
++ public int getShort(int offset) throws InvalidIndex {
++ if (offset < 0 || offset + 1 >= code.length)
++ throw new InvalidIndex(offset);
++ return (code[offset] << 8) | (code[offset + 1] & 0xFF);
++ }
++
++ public int getUnsignedShort(int offset) throws InvalidIndex {
++ if (offset < 0 || offset + 1 >= code.length)
++ throw new InvalidIndex(offset);
++ return ((code[offset] << 8) | (code[offset + 1] & 0xFF)) & 0xFFFF;
++ }
++
++ public int getInt(int offset) throws InvalidIndex {
++ if (offset < 0 || offset + 3 >= code.length)
++ throw new InvalidIndex(offset);
++ return (getShort(offset) << 16) | (getShort(offset + 2) & 0xFFFF);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitCode(this, data);
++ }
++
++ public final int max_stack;
++ public final int max_locals;
++ public final int code_length;
++ public final byte[] code;
++ public final int exception_table_langth;
++ public final Exception_data[] exception_table;
++ public final Attributes attributes;
++
++ public class Exception_data {
++ Exception_data(ClassReader cr) throws IOException {
++ start_pc = cr.readUnsignedShort();
++ end_pc = cr.readUnsignedShort();
++ handler_pc = cr.readUnsignedShort();
++ catch_type = cr.readUnsignedShort();
++ }
++
++ public final int start_pc;
++ public final int end_pc;
++ public final int handler_pc;
++ public final int catch_type;
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/CompilationID_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/CompilationID_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,62 @@
++/*
++ * 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.
++ */
++package com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class CompilationID_attribute extends Attribute {
++
++ CompilationID_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ compilationID_index = cr.readUnsignedShort();
++ }
++
++ public CompilationID_attribute(ConstantPool constant_pool, int compilationID_index)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.CompilationID), compilationID_index);
++ }
++
++ public CompilationID_attribute(int name_index, int compilationID_index) {
++ super(name_index, 2);
++ this.compilationID_index = compilationID_index;
++ }
++
++ String getCompilationID(ConstantPool constant_pool)
++ throws ConstantPoolException {
++ return constant_pool.getUTF8Value(compilationID_index);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitCompilationID(this, data);
++ }
++
++ public final int compilationID_index;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/ConstantPool.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,562 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.5.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ConstantPool {
++
++ public class InvalidIndex extends ConstantPoolException {
++ InvalidIndex(int index) {
++ super(index);
++ }
++
++ @Override
++ public String getMessage() {
++ // i18n
++ return "invalid index #" + index;
++ }
++ }
++
++ public class UnexpectedEntry extends ConstantPoolException {
++ UnexpectedEntry(int index, int expected_tag, int found_tag) {
++ super(index);
++ this.expected_tag = expected_tag;
++ this.found_tag = found_tag;
++ }
++
++ @Override
++ public String getMessage() {
++ // i18n?
++ return "unexpected entry at #" + index + " -- expected tag " + expected_tag + ", found " + found_tag;
++ }
++
++ public final int expected_tag;
++ public final int found_tag;
++ }
++
++ public class InvalidEntry extends ConstantPoolException {
++ InvalidEntry(int index, int tag) {
++ super(index);
++ this.tag = tag;
++ }
++
++ @Override
++ public String getMessage() {
++ // i18n?
++ return "unexpected tag at #" + index + ": " + tag;
++ }
++
++ public final int tag;
++ }
++
++ public class EntryNotFound extends ConstantPoolException {
++ EntryNotFound(Object value) {
++ super(-1);
++ this.value = value;
++ }
++
++ @Override
++ public String getMessage() {
++ // i18n?
++ return "value not found: " + value;
++ }
++
++ public final Object value;
++ }
++
++ public static final int CONSTANT_Utf8 = 1;
++ public static final int CONSTANT_Integer = 3;
++ public static final int CONSTANT_Float = 4;
++ public static final int CONSTANT_Long = 5;
++ public static final int CONSTANT_Double = 6;
++ public static final int CONSTANT_Class = 7;
++ public static final int CONSTANT_String = 8;
++ public static final int CONSTANT_Fieldref = 9;
++ public static final int CONSTANT_Methodref = 10;
++ public static final int CONSTANT_InterfaceMethodref = 11;
++ public static final int CONSTANT_NameAndType = 12;
++
++ ConstantPool(ClassReader cr) throws IOException, InvalidEntry {
++ int count = cr.readUnsignedShort();
++ pool = new CPInfo[count];
++ for (int i = 1; i < count; i++) {
++ int tag = cr.readUnsignedByte();
++ switch (tag) {
++ case CONSTANT_Class:
++ pool[i] = new CONSTANT_Class_info(this, cr);
++ break;
++
++ case CONSTANT_Double:
++ pool[i] = new CONSTANT_Double_info(cr);
++ i++;
++ break;
++
++ case CONSTANT_Fieldref:
++ pool[i] = new CONSTANT_Fieldref_info(this, cr);
++ break;
++
++ case CONSTANT_Float:
++ pool[i] = new CONSTANT_Float_info(cr);
++ break;
++
++ case CONSTANT_Integer:
++ pool[i] = new CONSTANT_Integer_info(cr);
++ break;
++
++ case CONSTANT_InterfaceMethodref:
++ pool[i] = new CONSTANT_InterfaceMethodref_info(this, cr);
++ break;
++
++ case CONSTANT_Long:
++ pool[i] = new CONSTANT_Long_info(cr);
++ i++;
++ break;
++
++ case CONSTANT_Methodref:
++ pool[i] = new CONSTANT_Methodref_info(this, cr);
++ break;
++
++ case CONSTANT_NameAndType:
++ pool[i] = new CONSTANT_NameAndType_info(this, cr);
++ break;
++
++ case CONSTANT_String:
++ pool[i] = new CONSTANT_String_info(cr);
++ break;
++
++ case CONSTANT_Utf8:
++ pool[i] = new CONSTANT_Utf8_info(cr);
++ break;
++
++ default:
++ throw new InvalidEntry(i, tag);
++ }
++ }
++ }
++
++ public ConstantPool(CPInfo[] pool) {
++ this.pool = pool;
++ }
++
++ public int size() {
++ return pool.length;
++ }
++
++ public CPInfo get(int index) throws InvalidIndex {
++ if (index <= 0 || index >= pool.length)
++ throw new InvalidIndex(index);
++ CPInfo info = pool[index];
++ if (info == null) {
++ // this occurs for indices referencing the "second half" of an
++ // 8 byte constant, such as CONSTANT_Double or CONSTANT_Long
++ throw new InvalidIndex(index);
++ }
++ return pool[index];
++ }
++
++ private CPInfo get(int index, int expected_type) throws InvalidIndex, UnexpectedEntry {
++ CPInfo info = get(index);
++ if (info.getTag() != expected_type)
++ throw new UnexpectedEntry(index, expected_type, info.getTag());
++ return info;
++ }
++
++ public CONSTANT_Utf8_info getUTF8Info(int index) throws InvalidIndex, UnexpectedEntry {
++ return ((CONSTANT_Utf8_info) get(index, CONSTANT_Utf8));
++ }
++
++ public CONSTANT_Class_info getClassInfo(int index) throws InvalidIndex, UnexpectedEntry {
++ return ((CONSTANT_Class_info) get(index, CONSTANT_Class));
++ }
++
++ public CONSTANT_NameAndType_info getNameAndTypeInfo(int index) throws InvalidIndex, UnexpectedEntry {
++ return ((CONSTANT_NameAndType_info) get(index, CONSTANT_NameAndType));
++ }
++
++ public String getUTF8Value(int index) throws InvalidIndex, UnexpectedEntry {
++ return getUTF8Info(index).value;
++ }
++
++ public int getUTF8Index(String value) throws EntryNotFound {
++ for (int i = 1; i < pool.length; i++) {
++ CPInfo info = pool[i];
++ if (info instanceof CONSTANT_Utf8_info &&
++ ((CONSTANT_Utf8_info) info).value.equals(value))
++ return i;
++ }
++ throw new EntryNotFound(value);
++ }
++
++ private CPInfo[] pool;
++
++ public interface Visitor<R,P> {
++ R visitClass(CONSTANT_Class_info info, P p);
++ R visitDouble(CONSTANT_Double_info info, P p);
++ R visitFieldref(CONSTANT_Fieldref_info info, P p);
++ R visitFloat(CONSTANT_Float_info info, P p);
++ R visitInteger(CONSTANT_Integer_info info, P p);
++ R visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, P p);
++ R visitLong(CONSTANT_Long_info info, P p);
++ R visitNameAndType(CONSTANT_NameAndType_info info, P p);
++ R visitMethodref(CONSTANT_Methodref_info info, P p);
++ R visitString(CONSTANT_String_info info, P p);
++ R visitUtf8(CONSTANT_Utf8_info info, P p);
++ }
++
++ public static abstract class CPInfo {
++ CPInfo() {
++ this.cp = null;
++ }
++
++ CPInfo(ConstantPool cp) {
++ this.cp = cp;
++ }
++
++ public abstract int getTag();
++
++ public abstract <R,D> R accept(Visitor<R,D> visitor, D data);
++
++ protected final ConstantPool cp;
++ }
++
++ public static abstract class CPRefInfo extends CPInfo {
++ protected CPRefInfo(ConstantPool cp, ClassReader cr, int tag) throws IOException {
++ super(cp);
++ this.tag = tag;
++ class_index = cr.readUnsignedShort();
++ name_and_type_index = cr.readUnsignedShort();
++ }
++
++ protected CPRefInfo(ConstantPool cp, int tag, int class_index, int name_and_type_index) {
++ super(cp);
++ this.tag = tag;
++ this.class_index = class_index;
++ this.name_and_type_index = name_and_type_index;
++ }
++
++ public int getTag() {
++ return tag;
++ }
++
++ public CONSTANT_Class_info getClassInfo() throws ConstantPoolException {
++ return cp.getClassInfo(class_index);
++ }
++
++ public String getClassName() throws ConstantPoolException {
++ return cp.getClassInfo(class_index).getName();
++ }
++
++ public CONSTANT_NameAndType_info getNameAndTypeInfo() throws ConstantPoolException {
++ return cp.getNameAndTypeInfo(name_and_type_index);
++ }
++
++ public final int tag;
++ public final int class_index;
++ public final int name_and_type_index;
++ }
++
++ public static class CONSTANT_Class_info extends CPInfo {
++ CONSTANT_Class_info(ConstantPool cp, ClassReader cr) throws IOException {
++ super(cp);
++ name_index = cr.readUnsignedShort();
++ }
++
++ public CONSTANT_Class_info(ConstantPool cp, int name_index) {
++ super(cp);
++ this.name_index = name_index;
++ }
++
++ public int getTag() {
++ return CONSTANT_Class;
++ }
++
++ public String getName() throws ConstantPoolException {
++ return cp.getUTF8Value(name_index);
++ }
++
++ @Override
++ public String toString() {
++ return "CONSTANT_Class_info[name_index: " + name_index + "]";
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitClass(this, data);
++ }
++
++ public final int name_index;
++ }
++
++ public static class CONSTANT_Double_info extends CPInfo {
++ CONSTANT_Double_info(ClassReader cr) throws IOException {
++ value = cr.readDouble();
++ }
++
++ public CONSTANT_Double_info(double value) {
++ this.value = value;
++ }
++
++ public int getTag() {
++ return CONSTANT_Double;
++ }
++
++ @Override
++ public String toString() {
++ return "CONSTANT_Double_info[value: " + value + "]";
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitDouble(this, data);
++ }
++
++ public final double value;
++ }
++
++ public static class CONSTANT_Fieldref_info extends CPRefInfo {
++ CONSTANT_Fieldref_info(ConstantPool cp, ClassReader cr) throws IOException {
++ super(cp, cr, CONSTANT_Fieldref);
++ }
++
++ public CONSTANT_Fieldref_info(ConstantPool cp, int class_index, int name_and_type_index) {
++ super(cp, CONSTANT_Fieldref, class_index, name_and_type_index);
++ }
++
++ @Override
++ public String toString() {
++ return "CONSTANT_Fieldref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]";
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitFieldref(this, data);
++ }
++ }
++
++ public static class CONSTANT_Float_info extends CPInfo {
++ CONSTANT_Float_info(ClassReader cr) throws IOException {
++ value = cr.readFloat();
++ }
++
++ public CONSTANT_Float_info(float value) {
++ this.value = value;
++ }
++
++ public int getTag() {
++ return CONSTANT_Float;
++ }
++
++ @Override
++ public String toString() {
++ return "CONSTANT_Float_info[value: " + value + "]";
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitFloat(this, data);
++ }
++
++ public final float value;
++ }
++
++ public static class CONSTANT_Integer_info extends CPInfo {
++ CONSTANT_Integer_info(ClassReader cr) throws IOException {
++ value = cr.readInt();
++ }
++
++ public CONSTANT_Integer_info(int value) {
++ this.value = value;
++ }
++
++ public int getTag() {
++ return CONSTANT_Integer;
++ }
++
++ @Override
++ public String toString() {
++ return "CONSTANT_Integer_info[value: " + value + "]";
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitInteger(this, data);
++ }
++
++ public final int value;
++ }
++
++ public static class CONSTANT_InterfaceMethodref_info extends CPRefInfo {
++ CONSTANT_InterfaceMethodref_info(ConstantPool cp, ClassReader cr) throws IOException {
++ super(cp, cr, CONSTANT_InterfaceMethodref);
++ }
++
++ public CONSTANT_InterfaceMethodref_info(ConstantPool cp, int class_index, int name_and_type_index) {
++ super(cp, CONSTANT_InterfaceMethodref, class_index, name_and_type_index);
++ }
++
++ @Override
++ public String toString() {
++ return "CONSTANT_InterfaceMethodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]";
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitInterfaceMethodref(this, data);
++ }
++ }
++
++ public static class CONSTANT_Long_info extends CPInfo {
++ CONSTANT_Long_info(ClassReader cr) throws IOException {
++ value = cr.readLong();
++ }
++
++ public CONSTANT_Long_info(long value) {
++ this.value = value;
++ }
++
++ public int getTag() {
++ return CONSTANT_Long;
++ }
++
++ @Override
++ public String toString() {
++ return "CONSTANT_Long_info[value: " + value + "]";
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitLong(this, data);
++ }
++
++ public final long value;
++ }
++
++ public static class CONSTANT_Methodref_info extends CPRefInfo {
++ CONSTANT_Methodref_info(ConstantPool cp, ClassReader cr) throws IOException {
++ super(cp, cr, CONSTANT_Methodref);
++ }
++
++ public CONSTANT_Methodref_info(ConstantPool cp, int class_index, int name_and_type_index) {
++ super(cp, CONSTANT_Methodref, class_index, name_and_type_index);
++ }
++
++ @Override
++ public String toString() {
++ return "CONSTANT_Methodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]";
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitMethodref(this, data);
++ }
++ }
++
++ public static class CONSTANT_NameAndType_info extends CPInfo {
++ CONSTANT_NameAndType_info(ConstantPool cp, ClassReader cr) throws IOException {
++ super(cp);
++ name_index = cr.readUnsignedShort();
++ type_index = cr.readUnsignedShort();
++ }
++
++ public CONSTANT_NameAndType_info(ConstantPool cp, int name_index, int type_index) {
++ super(cp);
++ this.name_index = name_index;
++ this.type_index = type_index;
++ }
++
++ public int getTag() {
++ return CONSTANT_NameAndType;
++ }
++
++ public String getName() throws ConstantPoolException {
++ return cp.getUTF8Value(name_index);
++ }
++
++ public String getType() throws ConstantPoolException {
++ return cp.getUTF8Value(type_index);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitNameAndType(this, data);
++ }
++
++ public final int name_index;
++ public final int type_index;
++ }
++
++ public static class CONSTANT_String_info extends CPInfo {
++ CONSTANT_String_info(ClassReader cr) throws IOException {
++ string_index = cr.readUnsignedShort();
++ }
++
++ public CONSTANT_String_info(ConstantPool cp, int string_index) {
++ super(cp);
++ this.string_index = string_index;
++ }
++
++ public int getTag() {
++ return CONSTANT_String;
++ }
++
++ public String getString() throws ConstantPoolException {
++ return cp.getUTF8Value(string_index);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitString(this, data);
++ }
++
++ public final int string_index;
++ }
++
++ public static class CONSTANT_Utf8_info extends CPInfo {
++ CONSTANT_Utf8_info(ClassReader cr) throws IOException {
++ value = cr.readUTF();
++ }
++
++ public CONSTANT_Utf8_info(String value) {
++ this.value = value;
++ }
++
++ public int getTag() {
++ return CONSTANT_Utf8;
++ }
++
++ @Override
++ public String toString() {
++ return "CONSTANT_Utf8_info[value: " + value + "]";
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitUtf8(this, data);
++ }
++
++ public final String value;
++ }
++
++
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/ConstantPoolException.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPoolException.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,41 @@
++/*
++ * 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.
++ */
++
++
++package com.sun.tools.classfile;
++
++/*
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ConstantPoolException extends Exception {
++ ConstantPoolException(int index) {
++ this.index = index;
++ }
++
++ public final int index;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/ConstantValue_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/ConstantValue_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,59 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.2.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ConstantValue_attribute extends Attribute {
++ ConstantValue_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ constantvalue_index = cr.readUnsignedShort();
++ }
++
++ public ConstantValue_attribute(ConstantPool constant_pool, int constantvalue_index)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.ConstantValue), constantvalue_index);
++ }
++
++ public ConstantValue_attribute(int name_index, int constantvalue_index) {
++ super(name_index, 2);
++ this.constantvalue_index = constantvalue_index;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitConstantValue(this, data);
++ }
++
++ public final int constantvalue_index;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/DefaultAttribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/DefaultAttribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,50 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++/*
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class DefaultAttribute extends Attribute {
++ DefaultAttribute(ClassReader cr, int name_index, byte[] data) {
++ super(name_index, data.length);
++ info = data;
++ }
++
++ public DefaultAttribute(ConstantPool constant_pool, int name_index, byte[] info) {
++ super(name_index, info.length);
++ this.info = info;
++ }
++
++ public <R, P> R accept(Visitor<R, P> visitor, P p) {
++ return visitor.visitDefault(this, p);
++ }
++
++ public final byte[] info;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Deprecated_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Deprecated_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,55 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.15.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Deprecated_attribute extends Attribute {
++ Deprecated_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ }
++
++ public Deprecated_attribute(ConstantPool constant_pool)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.Deprecated));
++ }
++
++ public Deprecated_attribute(int name_index) {
++ super(name_index, 0);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitDeprecated(this, data);
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Descriptor.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,198 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.4.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Descriptor {
++ public class InvalidDescriptor extends DescriptorException {
++ InvalidDescriptor(String desc) {
++ this.desc = desc;
++ this.index = -1;
++ }
++
++ InvalidDescriptor(String desc, int index) {
++ this.desc = desc;
++ this.index = index;
++ }
++
++ @Override
++ public String getMessage() {
++ // i18n
++ if (index == -1)
++ return "invalid descriptor \"" + desc + "\"";
++ else
++ return "descriptor is invalid at offset " + index + " in \"" + desc + "\"";
++ }
++
++ public final String desc;
++ public final int index;
++
++ }
++
++ public Descriptor(ClassReader cr) throws IOException {
++ this(cr.readUnsignedShort());
++ }
++
++ public Descriptor(int index) {
++ this.index = index;
++
++ }
++
++ public String getValue(ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(index);
++ }
++
++ public int getParameterCount(ConstantPool constant_pool)
++ throws ConstantPoolException, InvalidDescriptor {
++ String desc = getValue(constant_pool);
++ int end = desc.indexOf(")");
++ if (end == -1)
++ throw new InvalidDescriptor(desc);
++ parse(desc, 0, end + 1);
++ return count;
++
++ }
++
++ public String getParameterTypes(ConstantPool constant_pool)
++ throws ConstantPoolException, InvalidDescriptor {
++ String desc = getValue(constant_pool);
++ int end = desc.indexOf(")");
++ if (end == -1)
++ throw new InvalidDescriptor(desc);
++ return parse(desc, 0, end + 1);
++ }
++
++ public String getReturnType(ConstantPool constant_pool)
++ throws ConstantPoolException, InvalidDescriptor {
++ String desc = getValue(constant_pool);
++ int end = desc.indexOf(")");
++ if (end == -1)
++ throw new InvalidDescriptor(desc);
++ return parse(desc, end + 1, desc.length());
++ }
++
++ public String getFieldType(ConstantPool constant_pool)
++ throws ConstantPoolException, InvalidDescriptor {
++ String desc = getValue(constant_pool);
++ return parse(desc, 0, desc.length());
++ }
++
++ private String parse(String desc, int start, int end)
++ throws InvalidDescriptor {
++ int p = start;
++ StringBuffer sb = new StringBuffer();
++ int dims = 0;
++ count = 0;
++
++ while (p < end) {
++ String type;
++ char ch;
++ switch (ch = desc.charAt(p++)) {
++ case '(':
++ sb.append('(');
++ continue;
++
++ case ')':
++ sb.append(')');
++ continue;
++
++ case '[':
++ dims++;
++ continue;
++
++ case 'B':
++ type = "byte";
++ break;
++
++ case 'C':
++ type = "char";
++ break;
++
++ case 'D':
++ type = "double";
++ break;
++
++ case 'F':
++ type = "float";
++ break;
++
++ case 'I':
++ type = "int";
++ break;
++
++ case 'J':
++ type = "long";
++ break;
++
++ case 'L':
++ int sep = desc.indexOf(';', p);
++ if (sep == -1)
++ throw new InvalidDescriptor(desc, p - 1);
++ type = desc.substring(p, sep).replace('/', '.');
++ p = sep + 1;
++ break;
++
++ case 'S':
++ type = "short";
++ break;
++
++ case 'Z':
++ type = "boolean";
++ break;
++
++ case 'V':
++ type = "void";
++ break;
++
++ default:
++ throw new InvalidDescriptor(desc, p - 1);
++ }
++
++ if (sb.length() > 1 && sb.charAt(0) == '(')
++ sb.append(", ");
++ sb.append(type);
++ for ( ; dims > 0; dims-- )
++ sb.append("[]");
++
++ count++;
++ }
++
++ return sb.toString();
++ }
++
++ public final int index;
++ private int count;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/DescriptorException.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/DescriptorException.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,36 @@
++/*
++ * 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.
++ */
++
++
++package com.sun.tools.classfile;
++
++/*
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class DescriptorException extends Exception {
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/EnclosingMethod_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/EnclosingMethod_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,73 @@
++
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.7.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class EnclosingMethod_attribute extends Attribute {
++ EnclosingMethod_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ class_index = cr.readUnsignedShort();
++ method_index = cr.readUnsignedShort();
++ }
++
++ public EnclosingMethod_attribute(ConstantPool constant_pool, int class_index, int method_index)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.EnclosingMethod), class_index, method_index);
++ }
++
++ public EnclosingMethod_attribute(int name_index, int class_index, int method_index) {
++ super(name_index, 4);
++ this.class_index = class_index;
++ this.method_index = method_index;
++ }
++
++ public String getClassName(ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getClassInfo(class_index).getName();
++ }
++
++ public String getMethodName(ConstantPool constant_pool) throws ConstantPoolException {
++ if (method_index == 0)
++ return "";
++ return constant_pool.getNameAndTypeInfo(method_index).getName();
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitEnclosingMethod(this, data);
++ }
++
++ public final int class_index;
++ public final int method_index;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Exceptions_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Exceptions_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,69 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.5.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Exceptions_attribute extends Attribute {
++ Exceptions_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ number_of_exceptions = cr.readUnsignedShort();
++ exception_index_table = new int[number_of_exceptions];
++ for (int i = 0; i < number_of_exceptions; i++)
++ exception_index_table[i] = cr.readUnsignedShort();
++ }
++
++ public Exceptions_attribute(ConstantPool constant_pool, int[] exception_index_table)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.Exceptions), exception_index_table);
++ }
++
++ public Exceptions_attribute(int name_index, int[] exception_index_table) {
++ super(name_index, 2 + 2 * exception_index_table.length);
++ this.number_of_exceptions = exception_index_table.length;
++ this.exception_index_table = exception_index_table;
++ }
++
++ public String getException(int index, ConstantPool constant_pool) throws ConstantPoolException {
++ int exception_index = exception_index_table[index];
++ return constant_pool.getClassInfo(exception_index).getName();
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitExceptions(this, data);
++ }
++
++ public final int number_of_exceptions;
++ public final int[] exception_index_table;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Field.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Field.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,61 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/*
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Field {
++ Field(ClassReader cr) throws IOException {
++ access_flags = new AccessFlags(cr);
++ name_index = cr.readUnsignedShort();
++ descriptor = new Descriptor(cr);
++ attributes = new Attributes(cr);
++ }
++
++ public Field(AccessFlags access_flags,
++ int name_index, Descriptor descriptor,
++ Attributes attributes) {
++ this.access_flags = access_flags;
++ this.name_index = name_index;
++ this.descriptor = descriptor;
++ this.attributes = attributes;
++ }
++
++ public String getName(ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(name_index);
++ }
++
++ public final AccessFlags access_flags;
++ public final int name_index;
++ public final Descriptor descriptor;
++ public final Attributes attributes;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/InnerClasses_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/InnerClasses_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,102 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++import com.sun.tools.classfile.ConstantPool.*;
++
++/**
++ * See JVMS3, section 4.8.6.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class InnerClasses_attribute extends Attribute {
++ InnerClasses_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ number_of_classes = cr.readUnsignedShort();
++ classes = new Info[number_of_classes];
++ for (int i = 0; i < number_of_classes; i++)
++ classes[i] = new Info(cr);
++ }
++
++ public InnerClasses_attribute(ConstantPool constant_pool, Info[] classes)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.InnerClasses), classes);
++ }
++
++ public InnerClasses_attribute(int name_index, Info[] classes) {
++ super(name_index, 2 + Info.length() * classes.length);
++ this.number_of_classes = classes.length;
++ this.classes = classes;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitInnerClasses(this, data);
++ }
++
++ public final int number_of_classes;
++ public final Info[] classes;
++
++ public static class Info {
++ Info(ClassReader cr) throws IOException {
++ inner_class_info_index = cr.readUnsignedShort();
++ outer_class_info_index = cr.readUnsignedShort();
++ inner_name_index = cr.readUnsignedShort();
++ inner_class_access_flags = new AccessFlags(cr.readUnsignedShort());
++ }
++
++ public CONSTANT_Class_info getInnerClassInfo(ConstantPool constant_pool) throws ConstantPoolException {
++ if (inner_class_info_index == 0)
++ return null;
++ return constant_pool.getClassInfo(inner_class_info_index);
++ }
++
++ public CONSTANT_Class_info getOuterClassInfo(ConstantPool constant_pool) throws ConstantPoolException {
++ if (outer_class_info_index == 0)
++ return null;
++ return constant_pool.getClassInfo(outer_class_info_index);
++ }
++
++ public String getInnerName(ConstantPool constant_pool) throws ConstantPoolException {
++ if (inner_name_index == 0)
++ return null;
++ return constant_pool.getUTF8Value(inner_name_index);
++ }
++
++ public static int length() {
++ return 8;
++ }
++
++ public final int inner_class_info_index;
++ public final int outer_class_info_index;
++ public final int inner_name_index;
++ public final AccessFlags inner_class_access_flags;
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/LineNumberTable_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/LineNumberTable_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,78 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.12.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class LineNumberTable_attribute extends Attribute {
++ LineNumberTable_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ line_number_table_length = cr.readUnsignedShort();
++ line_number_table = new Entry[line_number_table_length];
++ for (int i = 0; i < line_number_table_length; i++)
++ line_number_table[i] = new Entry(cr);
++ }
++
++ public LineNumberTable_attribute(ConstantPool constant_pool, Entry[] line_number_table)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.LineNumberTable), line_number_table);
++ }
++
++ public LineNumberTable_attribute(int name_index, Entry[] line_number_table) {
++ super(name_index, line_number_table.length * Entry.length());
++ this.line_number_table_length = line_number_table.length;
++ this.line_number_table = line_number_table;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitLineNumberTable(this, data);
++ }
++
++ public final int line_number_table_length;
++ public final Entry[] line_number_table;
++
++ public static class Entry {
++ Entry(ClassReader cr) throws IOException {
++ start_pc = cr.readUnsignedShort();
++ line_number = cr.readUnsignedShort();
++ }
++
++ public static int length() {
++ return 4;
++ }
++
++ public final int start_pc;
++ public final int line_number;
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/LocalVariableTable_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/LocalVariableTable_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,84 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.13.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class LocalVariableTable_attribute extends Attribute {
++ LocalVariableTable_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ local_variable_table_length = cr.readUnsignedShort();
++ local_variable_table = new Entry[local_variable_table_length];
++ for (int i = 0; i < local_variable_table_length; i++)
++ local_variable_table[i] = new Entry(cr);
++ }
++
++ public LocalVariableTable_attribute(ConstantPool constant_pool, Entry[] local_variable_table)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.LocalVariableTable), local_variable_table);
++ }
++
++ public LocalVariableTable_attribute(int name_index, Entry[] local_variable_table) {
++ super(name_index, local_variable_table.length * Entry.length());
++ this.local_variable_table_length = local_variable_table.length;
++ this.local_variable_table = local_variable_table;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitLocalVariableTable(this, data);
++ }
++
++ public final int local_variable_table_length;
++ public final Entry[] local_variable_table;
++
++ public static class Entry {
++ Entry(ClassReader cr) throws IOException {
++ start_pc = cr.readUnsignedShort();
++ length = cr.readUnsignedShort();
++ name_index = cr.readUnsignedShort();
++ descriptor_index = cr.readUnsignedShort();
++ index = cr.readUnsignedShort();
++ }
++
++ public static int length() {
++ return 10;
++ }
++
++ public final int start_pc;
++ public final int length;
++ public final int name_index;
++ public final int descriptor_index;
++ public final int index;
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/LocalVariableTypeTable_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/LocalVariableTypeTable_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,84 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.14.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class LocalVariableTypeTable_attribute extends Attribute {
++ LocalVariableTypeTable_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ local_variable_table_length = cr.readUnsignedShort();
++ local_variable_table = new Entry[local_variable_table_length];
++ for (int i = 0; i < local_variable_table_length; i++)
++ local_variable_table[i] = new Entry(cr);
++ }
++
++ public LocalVariableTypeTable_attribute(ConstantPool constant_pool, Entry[] local_variable_table)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.LocalVariableTypeTable), local_variable_table);
++ }
++
++ public LocalVariableTypeTable_attribute(int name_index, Entry[] local_variable_table) {
++ super(name_index, local_variable_table.length * Entry.length());
++ this.local_variable_table_length = local_variable_table.length;
++ this.local_variable_table = local_variable_table;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitLocalVariableTypeTable(this, data);
++ }
++
++ public final int local_variable_table_length;
++ public final Entry[] local_variable_table;
++
++ public static class Entry {
++ Entry(ClassReader cr) throws IOException {
++ start_pc = cr.readUnsignedShort();
++ length = cr.readUnsignedShort();
++ name_index = cr.readUnsignedShort();
++ signature_index = cr.readUnsignedShort();
++ index = cr.readUnsignedShort();
++ }
++
++ public static int length() {
++ return 10;
++ }
++
++ public final int start_pc;
++ public final int length;
++ public final int name_index;
++ public final int signature_index;
++ public final int index;
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Method.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Method.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,61 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/*
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Method {
++ Method(ClassReader cr) throws IOException {
++ access_flags = new AccessFlags(cr);
++ name_index = cr.readUnsignedShort();
++ descriptor = new Descriptor(cr);
++ attributes = new Attributes(cr);
++ }
++
++ public Method(AccessFlags access_flags,
++ int name_index, Descriptor descriptor,
++ Attributes attributes) {
++ this.access_flags = access_flags;
++ this.name_index = name_index;
++ this.descriptor = descriptor;
++ this.attributes = attributes;
++ }
++
++ public String getName(ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(name_index);
++ }
++
++ public final AccessFlags access_flags;
++ public final int name_index;
++ public final Descriptor descriptor;
++ public final Attributes attributes;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/ModuleExportTable_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/ModuleExportTable_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,70 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JSR 277.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ModuleExportTable_attribute extends Attribute {
++ ModuleExportTable_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ int export_type_length = cr.readUnsignedShort();
++ export_type_table = new int[export_type_length];
++ for (int i = 0; i < export_type_table.length; i++)
++ export_type_table[i] = cr.readUnsignedShort();
++ }
++
++ public ModuleExportTable_attribute(ConstantPool cp, int[] export_type_table)
++ throws ConstantPoolException {
++ this(cp.getUTF8Index(Attribute.ModuleExportTable), export_type_table);
++ }
++
++ public ModuleExportTable_attribute(int name_index, int[] export_type_table) {
++ super(name_index, 2 * export_type_table.length);
++ this.export_type_table = export_type_table;
++ }
++
++ public int getExportTypeCount() {
++ return export_type_table.length;
++ }
++
++ public String getExportTypeName(int index, ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(export_type_table[index]);
++ }
++
++ public <R, P> R accept(Visitor<R, P> visitor, P p) {
++ return visitor.visitModuleExportTable(this, p);
++ }
++
++ public final int[] export_type_table;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/ModuleMemberTable_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/ModuleMemberTable_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,69 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JSR 277.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ModuleMemberTable_attribute extends Attribute {
++ ModuleMemberTable_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ int package_member_length = cr.readUnsignedShort();
++ package_member_table = new int[package_member_length];
++ for (int i = 0; i < package_member_table.length; i++)
++ package_member_table[i] = cr.readUnsignedShort();
++ }
++
++ public ModuleMemberTable_attribute(ConstantPool cp, int[] package_member_table)
++ throws ConstantPoolException {
++ this(cp.getUTF8Index(Attribute.ModuleMemberTable), package_member_table);
++ }
++
++ public ModuleMemberTable_attribute(int name_index, int[] package_member_table) {
++ super(name_index, 2 * package_member_table.length);
++ this.package_member_table = package_member_table;
++ }
++
++ public int getPackageMemberCount() {
++ return package_member_table.length;
++ }
++
++ public String getPackageMemberName(int index, ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(package_member_table[index]);
++ }
++
++ public <R, P> R accept(Visitor<R, P> visitor, P p) {
++ return visitor.visitModuleMemberTable(this, p);
++ }
++
++ public final int[] package_member_table;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Module_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Module_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,64 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JSR 277.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Module_attribute extends Attribute {
++ Module_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ module_name = cr.readUnsignedShort();
++ }
++
++ public Module_attribute(ConstantPool constant_pool, int module_name)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.Module), module_name);
++ }
++
++ public Module_attribute(int name_index, int module_name) {
++ super(name_index, 2);
++ this.module_name = module_name;
++ }
++
++ public String getModuleName(ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(module_name);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitModule(this, data);
++ }
++
++ public final int module_name;
++
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/OpCodes.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/OpCodes.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,868 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.util.HashMap;
++
++/**
++ * See JVMS3, section 6.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class OpCodes {
++
++ public static int opcLength(int opc) throws IllegalArgumentException {
++ switch (opc >> 8) {
++ case 0:
++ return opcLengthsTab[opc];
++ case opc_wide:
++ switch (opc & 0xFF) {
++ case opc_aload:
++ case opc_astore:
++ case opc_fload:
++ case opc_fstore:
++ case opc_iload:
++ case opc_istore:
++ case opc_lload:
++ case opc_lstore:
++ case opc_dload:
++ case opc_dstore:
++ case opc_ret:
++ return 4;
++ case opc_iinc:
++ return 6;
++ default:
++ throw new IllegalArgumentException();
++ }
++ case opc_nonpriv:
++ case opc_priv:
++ return 2;
++ default:
++ throw new IllegalArgumentException();
++ }
++ }
++
++ public static String opcName(int opc) {
++ try {
++ switch (opc >> 8) {
++ case 0:
++ return opcNamesTab[opc];
++ case opc_wide:
++ {
++ String mnem = opcNamesTab[opc & 0xFF] + "_w";
++ if (mnemocodes.get(mnem) == null) {
++ return null; // non-existent opcode
++ }
++ return mnem;
++ }
++ case opc_nonpriv:
++ return opcExtNamesTab[opc & 0xFF];
++ case opc_priv:
++ return opcPrivExtNamesTab[opc & 0xFF];
++ default:
++ return null;
++ }
++ } catch (ArrayIndexOutOfBoundsException e) {
++ switch (opc) {
++ case opc_nonpriv:
++ return "nonpriv";
++ case opc_priv:
++ return "priv";
++ default:
++ return null;
++ }
++ }
++ }
++
++ /* Opcodes */
++ public static final int opc_dead = -2;
++ public static final int opc_label = -1;
++ public static final int opc_nop = 0;
++ public static final int opc_aconst_null = 1;
++ public static final int opc_iconst_m1 = 2;
++ public static final int opc_iconst_0 = 3;
++ public static final int opc_iconst_1 = 4;
++ public static final int opc_iconst_2 = 5;
++ public static final int opc_iconst_3 = 6;
++ public static final int opc_iconst_4 = 7;
++ public static final int opc_iconst_5 = 8;
++ public static final int opc_lconst_0 = 9;
++ public static final int opc_lconst_1 = 10;
++ public static final int opc_fconst_0 = 11;
++ public static final int opc_fconst_1 = 12;
++ public static final int opc_fconst_2 = 13;
++ public static final int opc_dconst_0 = 14;
++ public static final int opc_dconst_1 = 15;
++ public static final int opc_bipush = 16;
++ public static final int opc_sipush = 17;
++ public static final int opc_ldc = 18;
++ public static final int opc_ldc_w = 19;
++ public static final int opc_ldc2_w = 20;
++ public static final int opc_iload = 21;
++ public static final int opc_lload = 22;
++ public static final int opc_fload = 23;
++ public static final int opc_dload = 24;
++ public static final int opc_aload = 25;
++ public static final int opc_iload_0 = 26;
++ public static final int opc_iload_1 = 27;
++ public static final int opc_iload_2 = 28;
++ public static final int opc_iload_3 = 29;
++ public static final int opc_lload_0 = 30;
++ public static final int opc_lload_1 = 31;
++ public static final int opc_lload_2 = 32;
++ public static final int opc_lload_3 = 33;
++ public static final int opc_fload_0 = 34;
++ public static final int opc_fload_1 = 35;
++ public static final int opc_fload_2 = 36;
++ public static final int opc_fload_3 = 37;
++ public static final int opc_dload_0 = 38;
++ public static final int opc_dload_1 = 39;
++ public static final int opc_dload_2 = 40;
++ public static final int opc_dload_3 = 41;
++ public static final int opc_aload_0 = 42;
++ public static final int opc_aload_1 = 43;
++ public static final int opc_aload_2 = 44;
++ public static final int opc_aload_3 = 45;
++ public static final int opc_iaload = 46;
++ public static final int opc_laload = 47;
++ public static final int opc_faload = 48;
++ public static final int opc_daload = 49;
++ public static final int opc_aaload = 50;
++ public static final int opc_baload = 51;
++ public static final int opc_caload = 52;
++ public static final int opc_saload = 53;
++ public static final int opc_istore = 54;
++ public static final int opc_lstore = 55;
++ public static final int opc_fstore = 56;
++ public static final int opc_dstore = 57;
++ public static final int opc_astore = 58;
++ public static final int opc_istore_0 = 59;
++ public static final int opc_istore_1 = 60;
++ public static final int opc_istore_2 = 61;
++ public static final int opc_istore_3 = 62;
++ public static final int opc_lstore_0 = 63;
++ public static final int opc_lstore_1 = 64;
++ public static final int opc_lstore_2 = 65;
++ public static final int opc_lstore_3 = 66;
++ public static final int opc_fstore_0 = 67;
++ public static final int opc_fstore_1 = 68;
++ public static final int opc_fstore_2 = 69;
++ public static final int opc_fstore_3 = 70;
++ public static final int opc_dstore_0 = 71;
++ public static final int opc_dstore_1 = 72;
++ public static final int opc_dstore_2 = 73;
++ public static final int opc_dstore_3 = 74;
++ public static final int opc_astore_0 = 75;
++ public static final int opc_astore_1 = 76;
++ public static final int opc_astore_2 = 77;
++ public static final int opc_astore_3 = 78;
++ public static final int opc_iastore = 79;
++ public static final int opc_lastore = 80;
++ public static final int opc_fastore = 81;
++ public static final int opc_dastore = 82;
++ public static final int opc_aastore = 83;
++ public static final int opc_bastore = 84;
++ public static final int opc_castore = 85;
++ public static final int opc_sastore = 86;
++ public static final int opc_pop = 87;
++ public static final int opc_pop2 = 88;
++ public static final int opc_dup = 89;
++ public static final int opc_dup_x1 = 90;
++ public static final int opc_dup_x2 = 91;
++ public static final int opc_dup2 = 92;
++ public static final int opc_dup2_x1 = 93;
++ public static final int opc_dup2_x2 = 94;
++ public static final int opc_swap = 95;
++ public static final int opc_iadd = 96;
++ public static final int opc_ladd = 97;
++ public static final int opc_fadd = 98;
++ public static final int opc_dadd = 99;
++ public static final int opc_isub = 100;
++ public static final int opc_lsub = 101;
++ public static final int opc_fsub = 102;
++ public static final int opc_dsub = 103;
++ public static final int opc_imul = 104;
++ public static final int opc_lmul = 105;
++ public static final int opc_fmul = 106;
++ public static final int opc_dmul = 107;
++ public static final int opc_idiv = 108;
++ public static final int opc_ldiv = 109;
++ public static final int opc_fdiv = 110;
++ public static final int opc_ddiv = 111;
++ public static final int opc_irem = 112;
++ public static final int opc_lrem = 113;
++ public static final int opc_frem = 114;
++ public static final int opc_drem = 115;
++ public static final int opc_ineg = 116;
++ public static final int opc_lneg = 117;
++ public static final int opc_fneg = 118;
++ public static final int opc_dneg = 119;
++ public static final int opc_ishl = 120;
++ public static final int opc_lshl = 121;
++ public static final int opc_ishr = 122;
++ public static final int opc_lshr = 123;
++ public static final int opc_iushr = 124;
++ public static final int opc_lushr = 125;
++ public static final int opc_iand = 126;
++ public static final int opc_land = 127;
++ public static final int opc_ior = 128;
++ public static final int opc_lor = 129;
++ public static final int opc_ixor = 130;
++ public static final int opc_lxor = 131;
++ public static final int opc_iinc = 132;
++ public static final int opc_i2l = 133;
++ public static final int opc_i2f = 134;
++ public static final int opc_i2d = 135;
++ public static final int opc_l2i = 136;
++ public static final int opc_l2f = 137;
++ public static final int opc_l2d = 138;
++ public static final int opc_f2i = 139;
++ public static final int opc_f2l = 140;
++ public static final int opc_f2d = 141;
++ public static final int opc_d2i = 142;
++ public static final int opc_d2l = 143;
++ public static final int opc_d2f = 144;
++ public static final int opc_i2b = 145;
++ public static final int opc_int2byte = 145;
++ public static final int opc_i2c = 146;
++ public static final int opc_int2char = 146;
++ public static final int opc_i2s = 147;
++ public static final int opc_int2short = 147;
++ public static final int opc_lcmp = 148;
++ public static final int opc_fcmpl = 149;
++ public static final int opc_fcmpg = 150;
++ public static final int opc_dcmpl = 151;
++ public static final int opc_dcmpg = 152;
++ public static final int opc_ifeq = 153;
++ public static final int opc_ifne = 154;
++ public static final int opc_iflt = 155;
++ public static final int opc_ifge = 156;
++ public static final int opc_ifgt = 157;
++ public static final int opc_ifle = 158;
++ public static final int opc_if_icmpeq = 159;
++ public static final int opc_if_icmpne = 160;
++ public static final int opc_if_icmplt = 161;
++ public static final int opc_if_icmpge = 162;
++ public static final int opc_if_icmpgt = 163;
++ public static final int opc_if_icmple = 164;
++ public static final int opc_if_acmpeq = 165;
++ public static final int opc_if_acmpne = 166;
++ public static final int opc_goto = 167;
++ public static final int opc_jsr = 168;
++ public static final int opc_ret = 169;
++ public static final int opc_tableswitch = 170;
++ public static final int opc_lookupswitch = 171;
++ public static final int opc_ireturn = 172;
++ public static final int opc_lreturn = 173;
++ public static final int opc_freturn = 174;
++ public static final int opc_dreturn = 175;
++ public static final int opc_areturn = 176;
++ public static final int opc_return = 177;
++ public static final int opc_getstatic = 178;
++ public static final int opc_putstatic = 179;
++ public static final int opc_getfield = 180;
++ public static final int opc_putfield = 181;
++ public static final int opc_invokevirtual = 182;
++ public static final int opc_invokenonvirtual = 183;
++ public static final int opc_invokespecial = 183;
++ public static final int opc_invokestatic = 184;
++ public static final int opc_invokeinterface = 185;
++// public static final int opc_xxxunusedxxx = 186;
++ public static final int opc_new = 187;
++ public static final int opc_newarray = 188;
++ public static final int opc_anewarray = 189;
++ public static final int opc_arraylength = 190;
++ public static final int opc_athrow = 191;
++ public static final int opc_checkcast = 192;
++ public static final int opc_instanceof = 193;
++ public static final int opc_monitorenter = 194;
++ public static final int opc_monitorexit = 195;
++ public static final int opc_wide = 196;
++ public static final int opc_multianewarray = 197;
++ public static final int opc_ifnull = 198;
++ public static final int opc_ifnonnull = 199;
++ public static final int opc_goto_w = 200;
++ public static final int opc_jsr_w = 201;
++
++ /* Pseudo-instructions */
++ public static final int opc_bytecode = 203;
++ public static final int opc_try = 204;
++ public static final int opc_endtry = 205;
++ public static final int opc_catch = 206;
++ public static final int opc_var = 207;
++ public static final int opc_endvar = 208;
++ public static final int opc_localsmap = 209;
++ public static final int opc_stackmap = 210;
++
++ /* PicoJava prefixes */
++ public static final int opc_nonpriv = 254;
++ public static final int opc_priv = 255;
++
++ /* Wide instructions */
++ public static final int opc_iload_w = (opc_wide << 8 ) | opc_iload;
++ public static final int opc_lload_w = (opc_wide << 8 ) | opc_lload;
++ public static final int opc_fload_w = (opc_wide << 8 ) | opc_fload;
++ public static final int opc_dload_w = (opc_wide << 8 ) | opc_dload;
++ public static final int opc_aload_w = (opc_wide << 8 ) | opc_aload;
++ public static final int opc_istore_w = (opc_wide << 8 ) | opc_istore;
++ public static final int opc_lstore_w = (opc_wide << 8 ) | opc_lstore;
++ public static final int opc_fstore_w = (opc_wide << 8 ) | opc_fstore;
++ public static final int opc_dstore_w = (opc_wide << 8 ) | opc_dstore;
++ public static final int opc_astore_w = (opc_wide << 8 ) | opc_astore;
++ public static final int opc_ret_w = (opc_wide << 8 ) | opc_ret;
++ public static final int opc_iinc_w = (opc_wide << 8 ) | opc_iinc;
++
++ /* Opcode Names */
++ private static final String opcNamesTab[] = {
++ "nop",
++ "aconst_null",
++ "iconst_m1",
++ "iconst_0",
++ "iconst_1",
++ "iconst_2",
++ "iconst_3",
++ "iconst_4",
++ "iconst_5",
++ "lconst_0",
++ "lconst_1",
++ "fconst_0",
++ "fconst_1",
++ "fconst_2",
++ "dconst_0",
++ "dconst_1",
++ "bipush",
++ "sipush",
++ "ldc",
++ "ldc_w",
++ "ldc2_w",
++ "iload",
++ "lload",
++ "fload",
++ "dload",
++ "aload",
++ "iload_0",
++ "iload_1",
++ "iload_2",
++ "iload_3",
++ "lload_0",
++ "lload_1",
++ "lload_2",
++ "lload_3",
++ "fload_0",
++ "fload_1",
++ "fload_2",
++ "fload_3",
++ "dload_0",
++ "dload_1",
++ "dload_2",
++ "dload_3",
++ "aload_0",
++ "aload_1",
++ "aload_2",
++ "aload_3",
++ "iaload",
++ "laload",
++ "faload",
++ "daload",
++ "aaload",
++ "baload",
++ "caload",
++ "saload",
++ "istore",
++ "lstore",
++ "fstore",
++ "dstore",
++ "astore",
++ "istore_0",
++ "istore_1",
++ "istore_2",
++ "istore_3",
++ "lstore_0",
++ "lstore_1",
++ "lstore_2",
++ "lstore_3",
++ "fstore_0",
++ "fstore_1",
++ "fstore_2",
++ "fstore_3",
++ "dstore_0",
++ "dstore_1",
++ "dstore_2",
++ "dstore_3",
++ "astore_0",
++ "astore_1",
++ "astore_2",
++ "astore_3",
++ "iastore",
++ "lastore",
++ "fastore",
++ "dastore",
++ "aastore",
++ "bastore",
++ "castore",
++ "sastore",
++ "pop",
++ "pop2",
++ "dup",
++ "dup_x1",
++ "dup_x2",
++ "dup2",
++ "dup2_x1",
++ "dup2_x2",
++ "swap",
++ "iadd",
++ "ladd",
++ "fadd",
++ "dadd",
++ "isub",
++ "lsub",
++ "fsub",
++ "dsub",
++ "imul",
++ "lmul",
++ "fmul",
++ "dmul",
++ "idiv",
++ "ldiv",
++ "fdiv",
++ "ddiv",
++ "irem",
++ "lrem",
++ "frem",
++ "drem",
++ "ineg",
++ "lneg",
++ "fneg",
++ "dneg",
++ "ishl",
++ "lshl",
++ "ishr",
++ "lshr",
++ "iushr",
++ "lushr",
++ "iand",
++ "land",
++ "ior",
++ "lor",
++ "ixor",
++ "lxor",
++ "iinc",
++ "i2l",
++ "i2f",
++ "i2d",
++ "l2i",
++ "l2f",
++ "l2d",
++ "f2i",
++ "f2l",
++ "f2d",
++ "d2i",
++ "d2l",
++ "d2f",
++ "i2b",
++ "i2c",
++ "i2s",
++ "lcmp",
++ "fcmpl",
++ "fcmpg",
++ "dcmpl",
++ "dcmpg",
++ "ifeq",
++ "ifne",
++ "iflt",
++ "ifge",
++ "ifgt",
++ "ifle",
++ "if_icmpeq",
++ "if_icmpne",
++ "if_icmplt",
++ "if_icmpge",
++ "if_icmpgt",
++ "if_icmple",
++ "if_acmpeq",
++ "if_acmpne",
++ "goto",
++ "jsr",
++ "ret",
++ "tableswitch",
++ "lookupswitch",
++ "ireturn",
++ "lreturn",
++ "freturn",
++ "dreturn",
++ "areturn",
++ "return",
++ "getstatic",
++ "putstatic",
++ "getfield",
++ "putfield",
++ "invokevirtual",
++ "invokespecial", // was "invokenonvirtual",
++ "invokestatic",
++ "invokeinterface",
++ "bytecode 186", //"xxxunusedxxx",
++ "new",
++ "newarray",
++ "anewarray",
++ "arraylength",
++ "athrow",
++ "checkcast",
++ "instanceof",
++ "monitorenter",
++ "monitorexit",
++ null, // "wide",
++ "multianewarray",
++ "ifnull",
++ "ifnonnull",
++ "goto_w",
++ "jsr_w",
++ "bytecode 202", // "breakpoint",
++ "bytecode",
++ "try",
++ "endtry",
++ "catch",
++ "var",
++ "endvar",
++ "locals_map",
++ "stack_map"
++ };
++
++ /* Opcode Lengths */
++ private static final int opcLengthsTab[] = {
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 2,
++ 3,
++ 2,
++ 3,
++ 3,
++ 2,
++ 2,
++ 2,
++ 2,
++ 2,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 2,
++ 2,
++ 2,
++ 2,
++ 2,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 3,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 2,
++ 99,
++ 99,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 1,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 3,
++ 5,
++ 0,
++ 3,
++ 2,
++ 3,
++ 1,
++ 1,
++ 3,
++ 3,
++ 1,
++ 1,
++ 0, // wide
++ 4,
++ 3,
++ 3,
++ 5,
++ 5,
++ 1,
++ 1, 0, 0, 0, 0, 0 // pseudo
++ };
++
++ /* Type codes, used in newarray opcode */
++ public static final int T_CLASS = 0x00000002;
++ public static final int T_BOOLEAN = 0x00000004;
++ public static final int T_CHAR = 0x00000005;
++ public static final int T_FLOAT = 0x00000006;
++ public static final int T_DOUBLE = 0x00000007;
++ public static final int T_BYTE = 0x00000008;
++ public static final int T_SHORT = 0x00000009;
++ public static final int T_INT = 0x0000000a;
++ public static final int T_LONG = 0x0000000b;
++
++ private static HashMap<String,Integer> mnemocodes = new HashMap<String,Integer>(301, 0.5f);
++ private static String opcExtNamesTab[]=new String[128];
++ private static String opcPrivExtNamesTab[]=new String[128];
++
++ private static void defineNonPriv(int opc, String mnem) {
++ mnemocodes.put(opcExtNamesTab[opc] = mnem, opc_nonpriv * 256 + opc);
++ }
++
++ private static void definePriv(int opc, String mnem) {
++ mnemocodes.put(opcPrivExtNamesTab[opc] = "priv_" + mnem, opc_priv * 256 + opc);
++ }
++
++ private static void defineExt(int opc, String mnem) {
++ defineNonPriv(opc, mnem);
++ definePriv(opc, mnem);
++ }
++
++ static {
++ for (int i = 0; i < opc_wide; i++) {
++ mnemocodes.put(opcNamesTab[i], i);
++ }
++ for (int i = opc_wide + 1; i < opcNamesTab.length; i++) {
++ mnemocodes.put(opcNamesTab[i], i);
++ }
++ mnemocodes.put("invokenonvirtual", opc_invokespecial);
++
++ mnemocodes.put("iload_w", opc_iload_w);
++ mnemocodes.put("lload_w", opc_lload_w);
++ mnemocodes.put("fload_w", opc_fload_w);
++ mnemocodes.put("dload_w", opc_dload_w);
++ mnemocodes.put("aload_w", opc_aload_w);
++ mnemocodes.put("istore_w", opc_istore_w);
++ mnemocodes.put("lstore_w", opc_lstore_w);
++ mnemocodes.put("fstore_w", opc_fstore_w);
++ mnemocodes.put("dstore_w", opc_dstore_w);
++ mnemocodes.put("astore_w", opc_astore_w);
++ mnemocodes.put("ret_w", opc_ret_w);
++ mnemocodes.put("iinc_w", opc_iinc_w);
++
++ mnemocodes.put("nonpriv", opc_nonpriv);
++ mnemocodes.put("priv", opc_priv);
++
++ defineExt(0, "load_ubyte");
++ defineExt(1, "load_byte");
++ defineExt(2, "load_char");
++ defineExt(3, "load_short");
++ defineExt(4, "load_word");
++ defineExt(10, "load_char_oe");
++ defineExt(11, "load_short_oe");
++ defineExt(12, "load_word_oe");
++ defineExt(16, "ncload_ubyte");
++ defineExt(17, "ncload_byte");
++ defineExt(18, "ncload_char");
++ defineExt(19, "ncload_short");
++ defineExt(20, "ncload_word");
++ defineExt(26, "ncload_char_oe");
++ defineExt(27, "ncload_short_oe");
++ defineExt(28, "ncload_word_oe");
++ defineExt(30, "cache_flush");
++ defineExt(32, "store_byte");
++ defineExt(34, "store_short");
++ defineExt(36, "store_word");
++ defineExt(42, "store_short_oe");
++ defineExt(44, "store_word_oe");
++ defineExt(48, "ncstore_byte");
++ defineExt(50, "ncstore_short");
++ defineExt(52, "ncstore_word");
++ defineExt(58, "ncstore_short_oe");
++ defineExt(60, "ncstore_word_oe");
++ defineExt(62, "zero_line");
++ defineNonPriv(5, "ret_from_sub");
++ defineNonPriv(63, "enter_sync_method");
++ definePriv(5, "ret_from_trap");
++ definePriv(6, "read_dcache_tag");
++ definePriv(7, "read_dcache_data");
++ definePriv(14, "read_icache_tag");
++ definePriv(15, "read_icache_data");
++ definePriv(22, "powerdown");
++ definePriv(23, "read_scache_data");
++ definePriv(31, "cache_index_flush");
++ definePriv(38, "write_dcache_tag");
++ definePriv(39, "write_dcache_data");
++ definePriv(46, "write_icache_tag");
++ definePriv(47, "write_icache_data");
++ definePriv(54, "reset");
++ definePriv(55, "write_scache_data");
++ for (int i = 0; i < 32; i++) {
++ definePriv(i + 64, "read_reg_" + i);
++ }
++ for (int i = 0; i < 32; i++) {
++ definePriv(i + 96, "write_reg_" + i);
++ }
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/RuntimeAnnotations_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/RuntimeAnnotations_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,61 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.16 and 4.8.17.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public abstract class RuntimeAnnotations_attribute extends Attribute {
++ protected RuntimeAnnotations_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, Annotation.InvalidAnnotation {
++ super(name_index, length);
++ int num_annotations = cr.readUnsignedShort();
++ annotations = new Annotation[num_annotations];
++ for (int i = 0; i < annotations.length; i++)
++ annotations[i] = new Annotation(cr);
++ }
++
++ protected RuntimeAnnotations_attribute(int name_index, Annotation[] annotations) {
++ super(name_index, length(annotations));
++ this.annotations = annotations;
++ }
++
++ private static int length(Annotation[] annos) {
++ int n = 2;
++ for (Annotation anno: annos)
++ n += anno.length();
++ return n;
++ }
++
++ public final Annotation[] annotations;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/RuntimeInvisibleAnnotations_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleAnnotations_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,56 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.17.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class RuntimeInvisibleAnnotations_attribute extends RuntimeAnnotations_attribute {
++ RuntimeInvisibleAnnotations_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, AttributeException {
++ super(cr, name_index, length);
++ }
++
++ public RuntimeInvisibleAnnotations_attribute(ConstantPool cp, Annotation[] annotations)
++ throws ConstantPoolException {
++ this(cp.getUTF8Index(Attribute.RuntimeInvisibleAnnotations), annotations);
++ }
++
++ public RuntimeInvisibleAnnotations_attribute(int name_index, Annotation[] annotations) {
++ super(name_index, annotations);
++ }
++
++ public <R, P> R accept(Visitor<R, P> visitor, P p) {
++ return visitor.visitRuntimeInvisibleAnnotations(this, p);
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/RuntimeInvisibleParameterAnnotations_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleParameterAnnotations_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,56 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.18.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class RuntimeInvisibleParameterAnnotations_attribute extends RuntimeParameterAnnotations_attribute {
++ RuntimeInvisibleParameterAnnotations_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, Annotation.InvalidAnnotation {
++ super(cr, name_index, length);
++ }
++
++ public RuntimeInvisibleParameterAnnotations_attribute(ConstantPool cp, Annotation[][] parameter_annotations)
++ throws ConstantPoolException {
++ this(cp.getUTF8Index(Attribute.RuntimeInvisibleParameterAnnotations), parameter_annotations);
++ }
++
++ public RuntimeInvisibleParameterAnnotations_attribute(int name_index, Annotation[][] parameter_annotations) {
++ super(name_index, parameter_annotations);
++ }
++
++ public <R, P> R accept(Visitor<R, P> visitor, P p) {
++ return visitor.visitRuntimeInvisibleParameterAnnotations(this, p);
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/RuntimeParameterAnnotations_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/RuntimeParameterAnnotations_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,70 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.18 and 4.8.19.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public abstract class RuntimeParameterAnnotations_attribute extends Attribute {
++ RuntimeParameterAnnotations_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, Annotation.InvalidAnnotation {
++ super(name_index, length);
++ int num_parameters = cr.readUnsignedByte();
++ parameter_annotations = new Annotation[num_parameters][];
++ for (int p = 0; p < parameter_annotations.length; p++) {
++ int num_annotations = cr.readUnsignedShort();
++ Annotation[] annotations = new Annotation[num_annotations];
++ for (int i = 0; i < num_annotations; i++)
++ annotations[i] = new Annotation(cr);
++ parameter_annotations[p] = annotations;
++ }
++ }
++
++ protected RuntimeParameterAnnotations_attribute(int name_index, Annotation[][] parameter_annotations) {
++ super(name_index, length(parameter_annotations));
++ this.parameter_annotations = parameter_annotations;
++ }
++
++ private static int length(Annotation[][] anno_arrays) {
++ int n = 1;
++ for (Annotation[] anno_array: anno_arrays) {
++ n += 2;
++ for (Annotation anno: anno_array)
++ n += anno.length();
++ }
++ return n;
++ }
++
++ public final Annotation[][] parameter_annotations;
++}
++
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/RuntimeVisibleAnnotations_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/RuntimeVisibleAnnotations_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,56 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.16.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class RuntimeVisibleAnnotations_attribute extends RuntimeAnnotations_attribute {
++ RuntimeVisibleAnnotations_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, Annotation.InvalidAnnotation {
++ super(cr, name_index, length);
++ }
++
++ public RuntimeVisibleAnnotations_attribute(ConstantPool cp, Annotation[] annotations)
++ throws ConstantPoolException {
++ this(cp.getUTF8Index(Attribute.RuntimeVisibleAnnotations), annotations);
++ }
++
++ public RuntimeVisibleAnnotations_attribute(int name_index, Annotation[] annotations) {
++ super(name_index, annotations);
++ }
++
++ public <R, P> R accept(Visitor<R, P> visitor, P p) {
++ return visitor.visitRuntimeVisibleAnnotations(this, p);
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/RuntimeVisibleParameterAnnotations_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/RuntimeVisibleParameterAnnotations_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,56 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.18.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class RuntimeVisibleParameterAnnotations_attribute extends RuntimeParameterAnnotations_attribute {
++ RuntimeVisibleParameterAnnotations_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, Annotation.InvalidAnnotation {
++ super(cr, name_index, length);
++ }
++
++ public RuntimeVisibleParameterAnnotations_attribute(ConstantPool cp, Annotation[][] parameter_annotations)
++ throws ConstantPoolException {
++ this(cp.getUTF8Index(Attribute.RuntimeVisibleParameterAnnotations), parameter_annotations);
++ }
++
++ public RuntimeVisibleParameterAnnotations_attribute(int name_index, Annotation[][] parameter_annotations) {
++ super(name_index, parameter_annotations);
++ }
++
++ public <R, P> R accept(Visitor<R, P> visitor, P p) {
++ return visitor.visitRuntimeVisibleParameterAnnotations(this, p);
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Signature.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Signature.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,275 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.util.ArrayList;
++import java.util.List;
++
++/**
++ * See JVMS3 4.4.4.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Signature extends Descriptor {
++
++ public Signature(int index) {
++ super(index);
++ }
++
++ public Type getType(ConstantPool constant_pool) throws ConstantPoolException {
++ if (type == null)
++ type = parse(getValue(constant_pool));
++ return type;
++ }
++
++ @Override
++ public int getParameterCount(ConstantPool constant_pool) throws ConstantPoolException {
++ Type.MethodType m = (Type.MethodType) getType(constant_pool);
++ return m.argTypes.size();
++ }
++
++ @Override
++ public String getParameterTypes(ConstantPool constant_pool) throws ConstantPoolException {
++ Type.MethodType m = (Type.MethodType) getType(constant_pool);
++ StringBuilder sb = new StringBuilder();
++ sb.append("(");
++ String sep = "";
++ for (Type argType: m.argTypes) {
++ sb.append(sep);
++ sb.append(argType);
++ sep = ", ";
++ }
++ sb.append(")");
++ return sb.toString();
++ }
++
++ @Override
++ public String getReturnType(ConstantPool constant_pool) throws ConstantPoolException {
++ Type.MethodType m = (Type.MethodType) getType(constant_pool);
++ return m.returnType.toString();
++ }
++
++ @Override
++ public String getFieldType(ConstantPool constant_pool) throws ConstantPoolException {
++ return getType(constant_pool).toString();
++ }
++
++ private Type parse(String sig) {
++ this.sig = sig;
++ sigp = 0;
++
++ List<Type> typeArgTypes = null;
++ if (sig.charAt(sigp) == '<')
++ typeArgTypes = parseTypeArgTypes();
++
++ if (sig.charAt(sigp) == '(') {
++ List<Type> argTypes = parseTypeSignatures(')');
++ Type returnType = parseTypeSignature();
++ List<Type> throwsTypes = null;
++ while (sigp < sig.length() && sig.charAt(sigp) == '^') {
++ sigp++;
++ if (throwsTypes == null)
++ throwsTypes = new ArrayList<Type>();
++ throwsTypes.add(parseTypeSignature());
++ }
++ return new Type.MethodType(typeArgTypes, argTypes, returnType, throwsTypes);
++ } else {
++ Type t = parseTypeSignature();
++ if (typeArgTypes == null && sigp == sig.length())
++ return t;
++ Type superclass = t;
++ List<Type> superinterfaces = new ArrayList<Type>();
++ while (sigp < sig.length())
++ superinterfaces.add(parseTypeSignature());
++ return new Type.ClassSigType(typeArgTypes, superclass, superinterfaces);
++
++ }
++ }
++
++ private Type parseTypeSignature() {
++ switch (sig.charAt(sigp)) {
++ case 'B':
++ sigp++;
++ return new Type.SimpleType("byte");
++
++ case 'C':
++ sigp++;
++ return new Type.SimpleType("char");
++
++ case 'D':
++ sigp++;
++ return new Type.SimpleType("double");
++
++ case 'F':
++ sigp++;
++ return new Type.SimpleType("float");
++
++ case 'I':
++ sigp++;
++ return new Type.SimpleType("int");
++
++ case 'J':
++ sigp++;
++ return new Type.SimpleType("long");
++
++ case 'L':
++ return parseClassTypeSignature();
++
++ case 'S':
++ sigp++;
++ return new Type.SimpleType("short");
++
++ case 'T':
++ return parseTypeVariableSignature();
++
++ case 'V':
++ sigp++;
++ return new Type.SimpleType("void");
++
++ case 'Z':
++ sigp++;
++ return new Type.SimpleType("boolean");
++
++ case '[':
++ sigp++;
++ return new Type.ArrayType(parseTypeSignature());
++
++ case '*':
++ sigp++;
++ return new Type.WildcardType();
++
++ case '+':
++ sigp++;
++ return new Type.WildcardType("extends", parseTypeSignature());
++
++ case '-':
++ sigp++;
++ return new Type.WildcardType("super", parseTypeSignature());
++
++ default:
++ throw new IllegalStateException(debugInfo());
++ }
++ }
++
++ private List<Type> parseTypeSignatures(char term) {
++ sigp++;
++ List<Type> types = new ArrayList<Type>();
++ while (sig.charAt(sigp) != term)
++ types.add(parseTypeSignature());
++ sigp++;
++ return types;
++ }
++
++ private Type parseClassTypeSignature() {
++ assert sig.charAt(sigp) == 'L';
++ sigp++;
++ return parseClassTypeSignatureRest();
++ }
++
++ private Type parseClassTypeSignatureRest() {
++ StringBuilder sb = new StringBuilder();
++ Type t = null;
++ char sigch;
++ while (true) {
++ switch (sigch = sig.charAt(sigp)) {
++ case '/':
++ sigp++;
++ sb.append(".");
++ break;
++
++ case '.':
++ sigp++;
++ if (t == null)
++ t = new Type.SimpleType(sb.toString());
++ return new Type.InnerClassType(t, parseClassTypeSignatureRest());
++
++ case ';':
++ sigp++;
++ if (t == null)
++ t = new Type.SimpleType(sb.toString());
++ return t;
++
++ case '<':
++ List<Type> argTypes = parseTypeSignatures('>');
++ t = new Type.ClassType(sb.toString(), argTypes);
++ break;
++
++ default:
++ sigp++;
++ sb.append(sigch);
++ break;
++ }
++ }
++ }
++
++ private List<Type> parseTypeArgTypes() {
++ assert sig.charAt(sigp) == '<';
++ sigp++;
++ List<Type> types = null;
++ types = new ArrayList<Type>();
++ while (sig.charAt(sigp) != '>')
++ types.add(parseTypeArgType());
++ sigp++;
++ return types;
++ }
++
++ private Type parseTypeArgType() {
++ int sep = sig.indexOf(":", sigp);
++ String name = sig.substring(sigp, sep);
++ Type classBound = null;
++ List<Type> interfaceBounds = null;
++ sigp = sep + 1;
++ if (sig.charAt(sigp) != ':')
++ classBound = parseTypeSignature();
++ while (sig.charAt(sigp) == ':') {
++ sigp++;
++ if (interfaceBounds == null)
++ interfaceBounds = new ArrayList<Type>();
++ interfaceBounds.add(parseTypeSignature());
++ }
++ return new Type.TypeArgType(name, classBound, interfaceBounds);
++ }
++
++ private Type parseTypeVariableSignature() {
++ sigp++;
++ int sep = sig.indexOf(';', sigp);
++ Type t = new Type.SimpleType(sig.substring(sigp, sep));
++ sigp = sep + 1;
++ return t;
++ }
++
++ private String debugInfo() {
++ return sig.substring(0, sigp) + "!" + sig.charAt(sigp) + "!" + sig.substring(sigp+1);
++ }
++
++ private String sig;
++ private int sigp;
++
++ private Type type;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Signature_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Signature_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,67 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.9.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Signature_attribute extends Attribute {
++ Signature_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ signature_index = cr.readUnsignedShort();
++ }
++
++ public Signature_attribute(ConstantPool constant_pool, int signature_index)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.Signature), signature_index);
++ }
++
++ public Signature_attribute(int name_index, int signature_index) {
++ super(name_index, 2);
++ this.signature_index = signature_index;
++ }
++
++ public String getSignature(ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(signature_index);
++ }
++
++ public Signature getParsedSignature() {
++ return new Signature(signature_index);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitSignature(this, data);
++ }
++
++ public final int signature_index;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/SourceDebugExtension_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/SourceDebugExtension_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,71 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.ByteArrayInputStream;
++import java.io.DataInputStream;
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.15.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class SourceDebugExtension_attribute extends Attribute {
++ SourceDebugExtension_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ debug_extension = new byte[attribute_length];
++ cr.readFully(debug_extension);
++ }
++
++ public SourceDebugExtension_attribute(ConstantPool constant_pool, byte[] debug_extension)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.SourceDebugExtension), debug_extension);
++ }
++
++ public SourceDebugExtension_attribute(int name_index, byte[] debug_extension) {
++ super(name_index, debug_extension.length);
++ this.debug_extension = debug_extension;
++ }
++
++ public String getValue() {
++ DataInputStream d = new DataInputStream(new ByteArrayInputStream(debug_extension));
++ try {
++ return d.readUTF();
++ } catch (IOException e) {
++ return null;
++ }
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitSourceDebugExtension(this, data);
++ }
++
++ public final byte[] debug_extension;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/SourceFile_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/SourceFile_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,63 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.10.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class SourceFile_attribute extends Attribute {
++ SourceFile_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ sourcefile_index = cr.readUnsignedShort();
++ }
++
++ public SourceFile_attribute(ConstantPool constant_pool, int sourcefile_index)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.SourceFile), sourcefile_index);
++ }
++
++ public SourceFile_attribute(int name_index, int sourcefile_index) {
++ super(name_index, 2);
++ this.sourcefile_index = sourcefile_index;
++ }
++
++ public String getSourceFile(ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(sourcefile_index);
++ }
++
++ public <R, P> R accept(Visitor<R, P> visitor, P p) {
++ return visitor.visitSourceFile(this, p);
++ }
++
++ public final int sourcefile_index;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/SourceID_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/SourceID_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,61 @@
++/*
++ * 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.
++ */
++package com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class SourceID_attribute extends Attribute {
++
++ SourceID_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ sourceID_index = cr.readUnsignedShort();
++ }
++
++ public SourceID_attribute(ConstantPool constant_pool, int sourceID_index)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.SourceID), sourceID_index);
++ }
++
++ public SourceID_attribute(int name_index, int sourceID_index) {
++ super(name_index, 2);
++ this.sourceID_index = sourceID_index;
++ }
++
++ String getSourceID(ConstantPool constant_pool) throws ConstantPoolException {
++ return constant_pool.getUTF8Value(sourceID_index);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitSourceID(this, data);
++ }
++
++ public final int sourceID_index;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,349 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.4.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class StackMapTable_attribute extends Attribute {
++ static class InvalidStackMap extends AttributeException {
++ InvalidStackMap(String msg) {
++ super(msg);
++ }
++ }
++
++ StackMapTable_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, InvalidStackMap {
++ super(name_index, length);
++ number_of_entries = cr.readUnsignedShort();
++ entries = new stack_map_frame[number_of_entries];
++ for (int i = 0; i < number_of_entries; i++)
++ entries[i] = stack_map_frame.read(cr);
++ }
++
++ public StackMapTable_attribute(ConstantPool constant_pool, stack_map_frame[] entries)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.StackMapTable), entries);
++ }
++
++ public StackMapTable_attribute(int name_index, stack_map_frame[] entries) {
++ super(name_index, length(entries));
++ this.number_of_entries = entries.length;
++ this.entries = entries;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitStackMapTable(this, data);
++ }
++
++ static int length(stack_map_frame[] entries) {
++ int n = 2;
++ for (stack_map_frame entry: entries)
++ n += entry.length();
++ return n;
++ }
++
++ public final int number_of_entries;
++ public final stack_map_frame entries[];
++
++ public static abstract class stack_map_frame {
++ static stack_map_frame read(ClassReader cr)
++ throws IOException, InvalidStackMap {
++ int frame_type = cr.readUnsignedByte();
++ if (frame_type <= 63)
++ return new same_frame(frame_type);
++ else if (frame_type <= 127)
++ return new same_locals_1_stack_item_frame(frame_type, cr);
++ else if (frame_type <= 246)
++ throw new Error("unknown frame_type " + frame_type);
++ else if (frame_type == 247)
++ return new same_locals_1_stack_item_frame_extended(frame_type, cr);
++ else if (frame_type <= 250)
++ return new chop_frame(frame_type, cr);
++ else if (frame_type == 251)
++ return new same_frame_extended(frame_type, cr);
++ else if (frame_type <= 254)
++ return new append_frame(frame_type, cr);
++ else
++ return new full_frame(frame_type, cr);
++ }
++
++ protected stack_map_frame(int frame_type) {
++ this.frame_type = frame_type;
++ }
++
++ public int length() {
++ return 1;
++ }
++
++ public abstract <R,D> R accept(Visitor<R,D> visitor, D data);
++
++ public final int frame_type;
++
++ public static interface Visitor<R,P> {
++ R visit_same_frame(same_frame frame, P p);
++ R visit_same_locals_1_stack_item_frame(same_locals_1_stack_item_frame frame, P p);
++ R visit_same_locals_1_stack_item_frame_extended(same_locals_1_stack_item_frame_extended frame, P p);
++ R visit_chop_frame(chop_frame frame, P p);
++ R visit_same_frame_extended(same_frame_extended frame, P p);
++ R visit_append_frame(append_frame frame, P p);
++ R visit_full_frame(full_frame frame, P p);
++ }
++ }
++
++ public static class same_frame extends stack_map_frame {
++ same_frame(int frame_type) {
++ super(frame_type);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visit_same_frame(this, data);
++ }
++ }
++
++ public static class same_locals_1_stack_item_frame extends stack_map_frame {
++ same_locals_1_stack_item_frame(int frame_type, ClassReader cr)
++ throws IOException, InvalidStackMap {
++ super(frame_type);
++ stack = new verification_type_info[1];
++ stack[0] = verification_type_info.read(cr);
++ }
++
++ @Override
++ public int length() {
++ return super.length() + stack[0].length();
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visit_same_locals_1_stack_item_frame(this, data);
++ }
++
++ public final verification_type_info[] stack;
++ }
++
++ public static class same_locals_1_stack_item_frame_extended extends stack_map_frame {
++ same_locals_1_stack_item_frame_extended(int frame_type, ClassReader cr)
++ throws IOException, InvalidStackMap {
++ super(frame_type);
++ offset_delta = cr.readUnsignedShort();
++ stack = new verification_type_info[1];
++ stack[0] = verification_type_info.read(cr);
++ }
++
++ @Override
++ public int length() {
++ return super.length() + 2 + stack[0].length();
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visit_same_locals_1_stack_item_frame_extended(this, data);
++ }
++
++ public final int offset_delta;
++ public final verification_type_info[] stack;
++ }
++
++ public static class chop_frame extends stack_map_frame {
++ chop_frame(int frame_type, ClassReader cr) throws IOException {
++ super(frame_type);
++ offset_delta = cr.readUnsignedShort();
++ }
++
++ @Override
++ public int length() {
++ return super.length() + 2;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visit_chop_frame(this, data);
++ }
++
++ public final int offset_delta;
++ }
++
++ public static class same_frame_extended extends stack_map_frame {
++ same_frame_extended(int frame_type, ClassReader cr) throws IOException {
++ super(frame_type);
++ offset_delta = cr.readUnsignedShort();
++ }
++
++ @Override
++ public int length() {
++ return super.length() + 2;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visit_same_frame_extended(this, data);
++ }
++
++ public final int offset_delta;
++ }
++
++ public static class append_frame extends stack_map_frame {
++ append_frame(int frame_type, ClassReader cr)
++ throws IOException, InvalidStackMap {
++ super(frame_type);
++ offset_delta = cr.readUnsignedShort();
++ locals = new verification_type_info[frame_type - 251];
++ for (int i = 0; i < locals.length; i++)
++ locals[i] = verification_type_info.read(cr);
++ }
++
++ @Override
++ public int length() {
++ int n = super.length() + 2;
++ for (verification_type_info local: locals)
++ n += local.length();
++ return n;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visit_append_frame(this, data);
++ }
++
++ public final int offset_delta;
++ public final verification_type_info[] locals;
++ }
++
++ public static class full_frame extends stack_map_frame {
++ full_frame(int frame_type, ClassReader cr)
++ throws IOException, InvalidStackMap {
++ super(frame_type);
++ offset_delta = cr.readUnsignedShort();
++ number_of_locals = cr.readUnsignedShort();
++ locals = new verification_type_info[number_of_locals];
++ for (int i = 0; i < locals.length; i++)
++ locals[i] = verification_type_info.read(cr);
++ number_of_stack_items = cr.readUnsignedShort();
++ stack = new verification_type_info[number_of_stack_items];
++ for (int i = 0; i < stack.length; i++)
++ stack[i] = verification_type_info.read(cr);
++ }
++
++ @Override
++ public int length() {
++ int n = super.length() + 2;
++ for (verification_type_info local: locals)
++ n += local.length();
++ n += 2;
++ for (verification_type_info item: stack)
++ n += item.length();
++ return n;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visit_full_frame(this, data);
++ }
++
++ public final int offset_delta;
++ public final int number_of_locals;
++ public final verification_type_info[] locals;
++ public final int number_of_stack_items;
++ public final verification_type_info[] stack;
++ }
++
++ public static class verification_type_info {
++ public static final int ITEM_Top = 0;
++ public static final int ITEM_Integer = 1;
++ public static final int ITEM_Float = 2;
++ public static final int ITEM_Long = 4;
++ public static final int ITEM_Double = 3;
++ public static final int ITEM_Null = 5;
++ public static final int ITEM_UninitializedThis = 6;
++ public static final int ITEM_Object = 7;
++ public static final int ITEM_Uninitialized = 8;
++
++ static verification_type_info read(ClassReader cr)
++ throws IOException, InvalidStackMap {
++ int tag = cr.readUnsignedByte();
++ switch (tag) {
++ case ITEM_Top:
++ case ITEM_Integer:
++ case ITEM_Float:
++ case ITEM_Long:
++ case ITEM_Double:
++ case ITEM_Null:
++ case ITEM_UninitializedThis:
++ return new verification_type_info(tag);
++
++ case ITEM_Object:
++ return new Object_variable_info(cr);
++
++ case ITEM_Uninitialized:
++ return new Uninitialized_variable_info(cr);
++
++ default:
++ throw new InvalidStackMap("unrecognized verification_type_info tag");
++ }
++ }
++
++ verification_type_info(int tag) {
++ this.tag = tag;
++ }
++
++ public int length() {
++ return 1;
++ }
++
++ public final int tag;
++ }
++
++ public static class Object_variable_info extends verification_type_info {
++ Object_variable_info(ClassReader cr) throws IOException {
++ super(ITEM_Object);
++ cpool_index = cr.readUnsignedShort();
++ }
++
++ @Override
++ public int length() {
++ return super.length() + 2;
++ }
++
++ public final int cpool_index;
++ }
++
++ public static class Uninitialized_variable_info extends verification_type_info {
++ Uninitialized_variable_info(ClassReader cr) throws IOException {
++ super(ITEM_Uninitialized);
++ offset = cr.readUnsignedShort();
++ }
++
++ @Override
++ public int length() {
++ return super.length() + 2;
++ }
++
++ public final int offset;
++
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/StackMap_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/StackMap_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,70 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class StackMap_attribute extends Attribute {
++ StackMap_attribute(ClassReader cr, int name_index, int length)
++ throws IOException, StackMapTable_attribute.InvalidStackMap {
++ super(name_index, length);
++ number_of_entries = cr.readUnsignedShort();
++ entries = new stack_map_frame[number_of_entries];
++ for (int i = 0; i < number_of_entries; i++)
++ entries[i] = new stack_map_frame(cr);
++ }
++
++ public StackMap_attribute(ConstantPool constant_pool, stack_map_frame[] entries)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.StackMap), entries);
++ }
++
++ public StackMap_attribute(int name_index, stack_map_frame[] entries) {
++ super(name_index, StackMapTable_attribute.length(entries));
++ this.number_of_entries = entries.length;
++ this.entries = entries;
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitStackMap(this, data);
++ }
++
++ public final int number_of_entries;
++ public final stack_map_frame entries[];
++
++ public static class stack_map_frame extends StackMapTable_attribute.full_frame {
++ stack_map_frame(ClassReader cr)
++ throws IOException, StackMapTable_attribute.InvalidStackMap {
++ super(255, cr);
++ }
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Synthetic_attribute.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Synthetic_attribute.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,55 @@
++/*
++ * Copyright 2007 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 com.sun.tools.classfile;
++
++import java.io.IOException;
++
++/**
++ * See JVMS3, section 4.8.8.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Synthetic_attribute extends Attribute {
++ Synthetic_attribute(ClassReader cr, int name_index, int length) throws IOException {
++ super(name_index, length);
++ }
++
++ public Synthetic_attribute(ConstantPool constant_pool)
++ throws ConstantPoolException {
++ this(constant_pool.getUTF8Index(Attribute.Synthetic));
++ }
++
++ public Synthetic_attribute(int name_index) {
++ super(name_index, 0);
++ }
++
++ public <R, D> R accept(Visitor<R, D> visitor, D data) {
++ return visitor.visitSynthetic(this, data);
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/Type.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Type.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,232 @@
++/*
++ * 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.
++ */
++
++package com.sun.tools.classfile;
++
++import java.util.List;
++
++/*
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Type {
++ protected Type() { }
++
++ public boolean isObject() {
++ return false;
++ }
++
++ protected static void append(StringBuilder sb, String prefix, List<? extends Type> types, String suffix) {
++ sb.append(prefix);
++ String sep = "";
++ for (Type t: types) {
++ sb.append(sep);
++ sb.append(t);
++ sep = ", ";
++ }
++ sb.append(suffix);
++ }
++
++ protected static void appendIfNotEmpty(StringBuilder sb, String prefix, List<? extends Type> types, String suffix) {
++ if (types != null && types.size() > 0)
++ append(sb, prefix, types, suffix);
++ }
++
++ public static class SimpleType extends Type {
++ public SimpleType(String name) {
++ this.name = name;
++ }
++
++ @Override
++ public String toString() {
++ return name;
++ }
++
++ @Override
++ public boolean isObject() {
++ return name.equals("java.lang.Object");
++ }
++
++ public final String name;
++ }
++
++ public static class ArrayType extends Type {
++ public ArrayType(Type elemType) {
++ this.elemType = elemType;
++ }
++
++ @Override
++ public String toString() {
++ return elemType + "[]";
++ }
++
++ public final Type elemType;
++ }
++
++ public static class MethodType extends Type {
++ public MethodType(List<? extends Type> argTypes, Type resultType) {
++ this(null, argTypes, resultType, null);
++ }
++
++ public MethodType(List<? extends Type> typeArgTypes,
++ List<? extends Type> argTypes,
++ Type returnType,
++ List<? extends Type> throwsTypes) {
++ this.typeArgTypes = typeArgTypes;
++ this.argTypes = argTypes;
++ this.returnType = returnType;
++ this.throwsTypes = throwsTypes;
++ }
++
++ @Override
++ public String toString() {
++ StringBuilder sb = new StringBuilder();
++ appendIfNotEmpty(sb, "<", typeArgTypes, "> ");
++ sb.append(returnType);
++ append(sb, " (", argTypes, ")");
++ appendIfNotEmpty(sb, " throws ", throwsTypes, "");
++ return sb.toString();
++ }
++
++ public final List<? extends Type> typeArgTypes;
++ public final List<? extends Type> argTypes;
++ public final Type returnType;
++ public final List<? extends Type> throwsTypes;
++ }
++
++ public static class ClassSigType extends Type {
++ public ClassSigType(List<Type> typeArgTypes, Type superclassType, List<Type> superinterfaceTypes) {
++ this.typeArgTypes = typeArgTypes;
++ this.superclassType = superclassType;
++ this.superinterfaceTypes = superinterfaceTypes;
++ }
++
++ @Override
++ public String toString() {
++ StringBuilder sb = new StringBuilder();
++ appendIfNotEmpty(sb, "<", typeArgTypes, ">");
++ if (superclassType != null && !superclassType.isObject()) {
++ sb.append(" extends ");
++ sb.append(superclassType);
++ }
++ appendIfNotEmpty(sb, " implements ", superinterfaceTypes, "");
++ return sb.toString();
++ }
++
++ public final List<Type> typeArgTypes;
++ public final Type superclassType;
++ public final List<Type> superinterfaceTypes;
++ }
++
++ public static class ClassType extends Type {
++ public ClassType(String name, List<Type> typeArgs) {
++ this.name = name;
++ this.typeArgs = typeArgs;
++ }
++
++ @Override
++ public String toString() {
++ StringBuilder sb = new StringBuilder();
++ sb.append(name);
++ appendIfNotEmpty(sb, "<", typeArgs, ">");
++ return sb.toString();
++ }
++
++ public final String name;
++ public final List<Type> typeArgs;
++ }
++
++
++ public static class InnerClassType extends Type {
++ public InnerClassType(Type outerType, Type innerType) {
++ this.outerType = outerType;
++ this.innerType = innerType;
++ }
++
++ @Override
++ public String toString() {
++ return outerType + "." + innerType;
++ }
++
++ public final Type outerType;
++ public final Type innerType;
++ }
++
++ public static class TypeArgType extends Type {
++ public TypeArgType(String name, Type classBound, List<Type> interfaceBounds) {
++ this.name = name;
++ this.classBound = classBound;
++ this.interfaceBounds = interfaceBounds;
++ }
++
++ @Override
++ public String toString() {
++ StringBuilder sb = new StringBuilder();
++ sb.append(name);
++ String sep = " extends ";
++ if (classBound != null && !classBound.isObject()) {
++ sb.append(sep);
++ sb.append(classBound);
++ sep = " & ";
++ }
++ if (interfaceBounds != null) {
++ for (Type bound: interfaceBounds) {
++ sb.append(sep);
++ sb.append(bound);
++ sep = " & ";
++ }
++ }
++ return sb.toString();
++ }
++
++ public final String name;
++ public final Type classBound;
++ public final List<Type> interfaceBounds;
++ }
++
++ public static class WildcardType extends Type {
++ public WildcardType() {
++ this(null, null);
++ }
++
++ public WildcardType(String kind, Type boundType) {
++ this.kind = kind;
++ this.boundType = boundType;
++ }
++
++ @Override
++ public String toString() {
++ if (kind == null)
++ return "?";
++ else
++ return "? " + kind + " " + boundType;
++ }
++
++ public final String kind;
++ public final Type boundType;
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/classfile/package.html
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/package.html Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,12 @@
++<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
++<html>
++ <head>
++ <title></title>
++ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
++ </head>
++ <body>
++ A minimalist library to read and write class files into objects closely
++ based on the corresponding definitions in the Java Virtual Machine
++ Specification (JVMS).
++ </body>
++</html>
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/AnnotationWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/AnnotationWriter.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,114 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import com.sun.tools.classfile.Annotation;
++import com.sun.tools.classfile.Annotation.Annotation_element_value;
++import com.sun.tools.classfile.Annotation.Array_element_value;
++import com.sun.tools.classfile.Annotation.Class_element_value;
++import com.sun.tools.classfile.Annotation.Enum_element_value;
++import com.sun.tools.classfile.Annotation.Primitive_element_value;
++
++/**
++ * A writer for writing annotations as text.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class AnnotationWriter extends BasicWriter {
++ static AnnotationWriter instance(Context context) {
++ AnnotationWriter instance = context.get(AnnotationWriter.class);
++ if (instance == null)
++ instance = new AnnotationWriter(context);
++ return instance;
++ }
++
++ protected AnnotationWriter(Context context) {
++ super(context);
++ }
++
++ public void write(Annotation annot) {
++ print("#" + annot.type_index + "(");
++ for (int i = 0; i < annot.num_element_value_pairs; i++) {
++ if (i > 0)
++ print(",");
++ write(annot.element_value_pairs[i]);
++ }
++ print(")");
++ }
++
++ public void write(Annotation.element_value_pair pair) {
++ print("#" + pair.element_name_index + ":");
++ write(pair.value);
++ }
++
++ public void write(Annotation.element_value value) {
++ ev_writer.write(value);
++ }
++
++ element_value_Writer ev_writer = new element_value_Writer();
++
++ class element_value_Writer implements Annotation.element_value.Visitor<Void,Void> {
++ public void write(Annotation.element_value value) {
++ value.accept(this, null);
++ }
++
++ public Void visitPrimitive(Primitive_element_value ev, Void p) {
++ print(((char) ev.tag) + "#" + ev.const_value_index);
++ return null;
++ }
++
++ public Void visitEnum(Enum_element_value ev, Void p) {
++ print(((char) ev.tag) + "#" + ev.type_name_index + ".#" + ev.const_name_index);
++ return null;
++ }
++
++ public Void visitClass(Class_element_value ev, Void p) {
++ print(((char) ev.tag) + "#" + ev.class_info_index);
++ return null;
++ }
++
++ public Void visitAnnotation(Annotation_element_value ev, Void p) {
++ print((char) ev.tag);
++ AnnotationWriter.this.write(ev.annotation_value);
++ return null;
++ }
++
++ public Void visitArray(Array_element_value ev, Void p) {
++ print("[");
++ for (int i = 0; i < ev.num_values; i++) {
++ if (i > 0)
++ print(",");
++ write(ev.values[i]);
++ }
++ print("]");
++ return null;
++ }
++
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/AttributeWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,679 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import java.util.Formatter;
++
++import com.sun.tools.classfile.AccessFlags;
++import com.sun.tools.classfile.AnnotationDefault_attribute;
++import com.sun.tools.classfile.Attribute;
++import com.sun.tools.classfile.Attributes;
++import com.sun.tools.classfile.CharacterRangeTable_attribute;
++import com.sun.tools.classfile.Code_attribute;
++import com.sun.tools.classfile.CompilationID_attribute;
++import com.sun.tools.classfile.ConstantPool;
++import com.sun.tools.classfile.ConstantPoolException;
++import com.sun.tools.classfile.ConstantValue_attribute;
++import com.sun.tools.classfile.DefaultAttribute;
++import com.sun.tools.classfile.Deprecated_attribute;
++import com.sun.tools.classfile.EnclosingMethod_attribute;
++import com.sun.tools.classfile.Exceptions_attribute;
++import com.sun.tools.classfile.Field;
++import com.sun.tools.classfile.InnerClasses_attribute;
++import com.sun.tools.classfile.LineNumberTable_attribute;
++import com.sun.tools.classfile.LocalVariableTable_attribute;
++import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
++import com.sun.tools.classfile.ModuleExportTable_attribute;
++import com.sun.tools.classfile.ModuleMemberTable_attribute;
++import com.sun.tools.classfile.Module_attribute;
++import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
++import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
++import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
++import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;
++import com.sun.tools.classfile.Signature_attribute;
++import com.sun.tools.classfile.SourceDebugExtension_attribute;
++import com.sun.tools.classfile.SourceFile_attribute;
++import com.sun.tools.classfile.SourceID_attribute;
++import com.sun.tools.classfile.StackMapTable_attribute;
++import com.sun.tools.classfile.StackMap_attribute;
++import com.sun.tools.classfile.Synthetic_attribute;
++
++import static com.sun.tools.classfile.AccessFlags.*;
++
++/*
++ * A writer for writing Attributes as text.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class AttributeWriter extends BasicWriter
++ implements Attribute.Visitor<Void,Void>
++{
++ static AttributeWriter instance(Context context) {
++ AttributeWriter instance = context.get(AttributeWriter.class);
++ if (instance == null)
++ instance = new AttributeWriter(context);
++ return instance;
++ }
++
++ protected AttributeWriter(Context context) {
++ super(context);
++ context.put(AttributeWriter.class, this);
++ annotationWriter = AnnotationWriter.instance(context);
++ codeWriter = CodeWriter.instance(context);
++ constantWriter = ConstantWriter.instance(context);
++ options = Options.instance(context);
++ }
++
++ public void write(Object owner, Attribute attr, ConstantPool constant_pool) {
++ if (attr != null) {
++ // null checks
++ owner.getClass();
++ constant_pool.getClass();
++ this.constant_pool = constant_pool;
++ this.owner = owner;
++ attr.accept(this, null);
++ }
++ }
++
++ public void write(Object owner, Attributes attrs, ConstantPool constant_pool) {
++ if (attrs != null) {
++ // null checks
++ owner.getClass();
++ constant_pool.getClass();
++ this.constant_pool = constant_pool;
++ this.owner = owner;
++ for (Attribute attr: attrs)
++ attr.accept(this, null);
++ }
++ }
++
++ public Void visitDefault(DefaultAttribute attr, Void ignore) {
++ byte[] data = attr.info;
++ int i = 0;
++ int j = 0;
++ print(" ");
++ try {
++ print(attr.getName(constant_pool));
++ } catch (ConstantPoolException e) {
++ report(e);
++ print("attribute name = #" + attr.attribute_name_index);
++ }
++ print(": ");
++ println("length = 0x" + toHex(attr.info.length));
++
++ print(" ");
++
++ while (i < data.length) {
++ print(toHex(data[i], 2));
++
++ j++;
++ if (j == 16) {
++ println();
++ print(" ");
++ j = 0;
++ } else {
++ print(" ");
++ }
++ i++;
++ }
++ println();
++ return null;
++ }
++
++ public Void visitAnnotationDefault(AnnotationDefault_attribute attr, Void ignore) {
++ println(" AnnotationDefault: ");
++ print(" default_value: ");
++ annotationWriter.write(attr.default_value);
++ return null;
++ }
++
++ public Void visitCharacterRangeTable(CharacterRangeTable_attribute attr, Void ignore) {
++ print(" CharacterRangeTable: ");
++ for (int i = 0; i < attr.character_range_table.length; i++) {
++ CharacterRangeTable_attribute.Entry e = attr.character_range_table[i];
++ print(" " + e.start_pc + ", " +
++ e.end_pc + ", " +
++ Integer.toHexString(e.character_range_start) + ", " +
++ Integer.toHexString(e.character_range_end) + ", " +
++ Integer.toHexString(e.flags) +
++ "\t// ");
++ print(e.start_pc + ", " +
++ e.end_pc + ", " +
++ (e.character_range_start >> 10) + ":" + (e.character_range_start & 0x3ff) + ", " +
++ (e.character_range_end >> 10) + ":" + (e.character_range_end & 0x3ff));
++ if ((e.flags & CharacterRangeTable_attribute.CRT_STATEMENT) != 0)
++ print(", statement");
++ if ((e.flags & CharacterRangeTable_attribute.CRT_BLOCK) != 0)
++ print(", block");
++ if ((e.flags & CharacterRangeTable_attribute.CRT_ASSIGNMENT) != 0)
++ print(", assignment");
++ if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_CONTROLLER) != 0)
++ print(", flow-controller");
++ if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_TARGET) != 0)
++ print(", flow-target");
++ if ((e.flags & CharacterRangeTable_attribute.CRT_INVOKE) != 0)
++ print(", invoke");
++ if ((e.flags & CharacterRangeTable_attribute.CRT_CREATE) != 0)
++ print(", create");
++ if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_TRUE) != 0)
++ print(", branch-true");
++ if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_FALSE) != 0)
++ print(", branch-false");
++
++
++
++ }
++ return null;
++ }
++
++ public Void visitCode(Code_attribute attr, Void ignore) {
++ codeWriter.write(attr, constant_pool);
++ println();
++ return null;
++ }
++
++ public Void visitCompilationID(CompilationID_attribute attr, Void ignore) {
++ constantWriter.write(attr.compilationID_index);
++ return null;
++ }
++
++ public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) {
++ if (options.compat) // BUG 6622216 javap names some attributes incorrectly
++ print(" Constant value: ");
++ else
++ print(" ConstantValue: ");
++ constantWriter.write(attr.constantvalue_index);
++ if (!options.compat) // BUG 6622232 javap gets whitespace confused
++ println();
++ return null;
++ }
++
++ public Void visitDeprecated(Deprecated_attribute attr, Void ignore) {
++ if (!(options.compat && owner instanceof Field)) // BUG 6622232 javap gets whitespace confused
++ print(" ");
++ println("Deprecated: true");
++ return null;
++ }
++
++ public Void visitEnclosingMethod(EnclosingMethod_attribute attr, Void ignore) {
++ print(" EnclosingMethod: #" + attr.class_index + ".#" + attr.method_index
++ + "\t// " + getJavaClassName(attr));
++ if (attr.method_index != 0)
++ print("." + getMethodName(attr));
++ println();
++ return null;
++ }
++
++ private String getJavaClassName(EnclosingMethod_attribute a) {
++ try {
++ return getJavaName(a.getClassName(constant_pool));
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ private String getMethodName(EnclosingMethod_attribute a) {
++ try {
++ return a.getMethodName(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public Void visitExceptions(Exceptions_attribute attr, Void ignore) {
++ println(" Exceptions: ");
++ print(" throws ");
++ for (int i = 0; i < attr.number_of_exceptions; i++) {
++ if (i > 0)
++ print(", ");
++ print(getJavaException(attr, i));
++ }
++ if (!options.compat) // BUG 6622232 javap gets whitespace confused
++ println();
++ return null;
++ }
++
++ String getJavaException(Exceptions_attribute attr, int index) {
++ try {
++ return getJavaName(attr.getException(index, constant_pool));
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) {
++ boolean first = true;
++ if (options.compat) {
++ writeInnerClassHeader();
++ first = false;
++ }
++ for (int i = 0 ; i < attr.classes.length; i++) {
++ InnerClasses_attribute.Info info = attr.classes[i];
++ //access
++ AccessFlags access_flags = info.inner_class_access_flags;
++ if (options.compat) {
++ // BUG 6622215: javap ignores certain relevant access flags
++ access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM);
++ // BUG 6622232: javap gets whitespace confused
++ print(" ");
++ }
++ if (options.checkAccess(access_flags)) {
++ if (first) {
++ writeInnerClassHeader();
++ first = false;
++ }
++ if (!options.compat) // BUG 6622232: javap gets whitespace confused
++ print(" ");
++ for (String name: access_flags.getInnerClassModifiers())
++ print(name + " ");
++ if (info.inner_name_index!=0) {
++ print("#" + info.inner_name_index + "= ");
++ }
++ print("#" + info.inner_class_info_index);
++ if (info.outer_class_info_index != 0) {
++ print(" of #" + info.outer_class_info_index);
++ }
++ print("; //");
++ if (info.inner_name_index != 0) {
++ print(getInnerName(constant_pool, info) + "=");
++ }
++ constantWriter.write(info.inner_class_info_index);
++ if (info.outer_class_info_index != 0) {
++ print(" of ");
++ constantWriter.write(info.outer_class_info_index);
++ }
++ println();
++ }
++ }
++ return null;
++ }
++
++ String getInnerName(ConstantPool constant_pool, InnerClasses_attribute.Info info) {
++ try {
++ return info.getInnerName(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ private void writeInnerClassHeader() {
++ print(" ");
++ if (options.compat) // BUG 6622216: javap names some attributes incorrectly
++ print("InnerClass");
++ else
++ print("InnerClasses");
++ println(": ");
++ }
++
++ public Void visitLineNumberTable(LineNumberTable_attribute attr, Void ignore) {
++ println(" LineNumberTable: ");
++ for (LineNumberTable_attribute.Entry entry: attr.line_number_table) {
++ println(" line " + entry.line_number + ": " + entry.start_pc);
++ }
++ return null;
++ }
++
++ public Void visitLocalVariableTable(LocalVariableTable_attribute attr, Void ignore) {
++ println(" LocalVariableTable: ");
++ println(" Start Length Slot Name Signature");
++
++ for (LocalVariableTable_attribute.Entry entry : attr.local_variable_table) {
++ Formatter formatter = new Formatter();
++ println(formatter.format("%8d %7d %5d %5s %s",
++ entry.start_pc, entry.length, entry.index,
++ constantWriter.stringValue(entry.name_index),
++ constantWriter.stringValue(entry.descriptor_index)));
++ }
++ return null;
++ }
++
++ public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, Void ignore) {
++ println(" LocalVariableTypeTable: ");
++ println(" Start Length Slot Name Signature");
++
++ for (LocalVariableTypeTable_attribute.Entry entry : attr.local_variable_table) {
++ Formatter formatter = new Formatter();
++ println(formatter.format("%8d %7d %5d %5s %s",
++ entry.start_pc, entry.length, entry.index,
++ constantWriter.stringValue(entry.name_index),
++ constantWriter.stringValue(entry.signature_index)));
++ }
++ return null;
++ }
++
++ public Void visitModule(Module_attribute attr, Void ignore) {
++ println(" Module: #" + attr.module_name + "\t// " + getModuleName(attr));
++ return null;
++ }
++
++ String getModuleName(Module_attribute attr) {
++ try {
++ return attr.getModuleName(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public Void visitModuleExportTable(ModuleExportTable_attribute attr, Void ignore) {
++ println(" ModuleExportTable:");
++ println(" Types: (" + attr.export_type_table.length + ")");
++ for (int i = 0; i < attr.export_type_table.length; i++) {
++ println(" #" + attr.export_type_table[i] + "\t// " + getExportTypeName(attr, i));
++ }
++ return null;
++ }
++
++ String getExportTypeName(ModuleExportTable_attribute attr, int index) {
++ try {
++ return attr.getExportTypeName(index, constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public Void visitModuleMemberTable(ModuleMemberTable_attribute attr, Void ignore) {
++ println(" ModuleMemberTable:");
++ println(" Packages: (" + attr.package_member_table.length + ")");
++ for (int i = 0; i < attr.package_member_table.length; i++) {
++ println(" #" + attr.package_member_table[i] + "\t// " + getPackageMemberName(attr, i));
++ }
++ return null;
++ }
++
++ String getPackageMemberName(ModuleMemberTable_attribute attr, int index) {
++ try {
++ return attr.getPackageMemberName(index, constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
++ println(" RuntimeVisibleAnnotations: ");
++ for (int i = 0; i < attr.annotations.length; i++) {
++ print(" " + i + ": ");
++ annotationWriter.write(attr.annotations[i]);
++ println();
++ }
++ return null;
++ }
++
++ public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, Void ignore) {
++ println(" RuntimeInvisibleAnnotations: ");
++ for (int i = 0; i < attr.annotations.length; i++) {
++ print(" " + i + ": ");
++ annotationWriter.write(attr.annotations[i]);
++ println();
++ }
++ return null;
++ }
++
++ public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) {
++ println(" RuntimeVisibleParameterAnnotations: ");
++ for (int param = 0; param < attr.parameter_annotations.length; param++) {
++ println(" parameter " + param + ": ");
++ for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
++ print(" " + i + ": ");
++ annotationWriter.write(attr.parameter_annotations[param][i]);
++ println();
++ }
++ }
++ return null;
++ }
++
++ public Void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, Void ignore) {
++ println(" RuntimeInvisibleParameterAnnotations: ");
++ for (int param = 0; param < attr.parameter_annotations.length; param++) {
++ println(" " + param + ": ");
++ for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
++ print(" " + i + ": ");
++ annotationWriter.write(attr.parameter_annotations[param][i]);
++ println();
++ }
++ }
++ return null;
++ }
++
++ public Void visitSignature(Signature_attribute attr, Void ignore) {
++ println(" Signature: #" + attr.signature_index + "\t// " + getSignature(attr));
++ return null;
++ }
++
++ String getSignature(Signature_attribute info) {
++ try {
++ return info.getSignature(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) {
++ println(" SourceDebugExtension: " + attr.getValue());
++ return null;
++ }
++
++ public Void visitSourceFile(SourceFile_attribute attr, Void ignore) {
++ println(" SourceFile: \"" + getSourceFile(attr) + "\"");
++ return null;
++ }
++
++ private String getSourceFile(SourceFile_attribute attr) {
++ try {
++ return attr.getSourceFile(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public Void visitSourceID(SourceID_attribute attr, Void ignore) {
++ constantWriter.write(attr.sourceID_index);
++ return null;
++ }
++
++ public Void visitStackMap(StackMap_attribute attr, Void ignore) {
++ println(" StackMap: number_of_entries = " + attr.number_of_entries);
++
++ StackMapTableWriter w = new StackMapTableWriter();
++ for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
++ w.write(entry);
++ }
++ println();
++ return null;
++ }
++
++ public Void visitStackMapTable(StackMapTable_attribute attr, Void ignore) {
++ println(" StackMapTable: number_of_entries = " + attr.number_of_entries);
++
++ StackMapTableWriter w = new StackMapTableWriter();
++ for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
++ w.write(entry);
++ }
++ println();
++ return null;
++ }
++
++ class StackMapTableWriter // also handles CLDC StackMap attributes
++ implements StackMapTable_attribute.stack_map_frame.Visitor<Void,Void> {
++ public void write(StackMapTable_attribute.stack_map_frame frame) {
++ frame.accept(this, null);
++ }
++
++ public Void visit_same_frame(StackMapTable_attribute.same_frame frame, Void p) {
++ printHeader(frame);
++ println(" /* same */");
++ return null;
++ }
++
++ public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) {
++ printHeader(frame);
++ println(" /* same_locals_1_stack_item */");
++ printMap("stack", frame.stack);
++ return null;
++ }
++
++ public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) {
++ printHeader(frame);
++ println(" /* same_locals_1_stack_item_frame_extended */");
++ println(" offset_delta = " + frame.offset_delta);
++ printMap("stack", frame.stack);
++ return null;
++ }
++
++ public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) {
++ printHeader(frame);
++ println(" /* chop */");
++ println(" offset_delta = " + frame.offset_delta);
++ return null;
++ }
++
++ public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) {
++ printHeader(frame);
++ println(" /* same_frame_extended */");
++ println(" offset_delta = " + frame.offset_delta);
++ return null;
++ }
++
++ public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) {
++ printHeader(frame);
++ println(" /* append */");
++ println(" offset_delta = " + frame.offset_delta);
++ printMap("locals", frame.locals);
++ return null;
++ }
++
++ public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) {
++ printHeader(frame);
++ if (frame instanceof StackMap_attribute.stack_map_frame) {
++ println(" offset = " + frame.offset_delta);
++ } else {
++ println(" /* full_frame */");
++ println(" offset_delta = " + frame.offset_delta);
++ }
++ printMap("locals", frame.locals);
++ printMap("stack", frame.stack);
++ return null;
++ }
++
++ void printHeader(StackMapTable_attribute.stack_map_frame frame) {
++ print(" frame_type = " + frame.frame_type);
++ }
++
++ void printMap(String name, StackMapTable_attribute.verification_type_info[] map) {
++ print(" " + name + " = [");
++ for (int i = 0; i < map.length; i++) {
++ StackMapTable_attribute.verification_type_info info = map[i];
++ int tag = info.tag;
++ switch (tag) {
++ case StackMapTable_attribute.verification_type_info.ITEM_Object:
++ print(" ");
++ constantWriter.write(((StackMapTable_attribute.Object_variable_info) info).cpool_index);
++ break;
++ case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
++ print(" " + mapTypeName(tag));
++ print(" " + ((StackMapTable_attribute.Uninitialized_variable_info) info).offset);
++ break;
++ default:
++ print(" " + mapTypeName(tag));
++ }
++ print(i == (map.length - 1) ? " " : ",");
++ }
++ println("]");
++ }
++
++ String mapTypeName(int tag) {
++ switch (tag) {
++ case StackMapTable_attribute.verification_type_info.ITEM_Top:
++ return "top";
++
++ case StackMapTable_attribute.verification_type_info.ITEM_Integer:
++ return "int";
++
++ case StackMapTable_attribute.verification_type_info.ITEM_Float:
++ return "float";
++
++ case StackMapTable_attribute.verification_type_info.ITEM_Long:
++ return "long";
++
++ case StackMapTable_attribute.verification_type_info.ITEM_Double:
++ return "double";
++
++ case StackMapTable_attribute.verification_type_info.ITEM_Null:
++ return "null";
++
++ case StackMapTable_attribute.verification_type_info.ITEM_UninitializedThis:
++ return "this";
++
++ case StackMapTable_attribute.verification_type_info.ITEM_Object:
++ return "CP";
++
++ case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
++ return "uninitialized";
++
++ default:
++ report("unrecognized verification_type_info tag: " + tag);
++ return "[tag:" + tag + "]";
++ }
++ }
++ }
++
++ public Void visitSynthetic(Synthetic_attribute attr, Void ignore) {
++ println("Synthetic: true");
++ return null;
++ }
++
++ static String getJavaName(String name) {
++ return name.replace('/', '.');
++ }
++
++ String toHex(byte b, int w) {
++ if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex
++ return toHex((int) b, w);
++ else
++ return toHex(b & 0xff, w);
++ }
++
++ static String toHex(int i) {
++ return Integer.toString(i, 16).toUpperCase();
++ }
++
++ static String toHex(int i, int w) {
++ String s = Integer.toHexString(i).toUpperCase();
++ while (s.length() < w)
++ s = "0" + s;
++ return s.toUpperCase();
++ }
++
++ private AnnotationWriter annotationWriter;
++ private CodeWriter codeWriter;
++ private ConstantWriter constantWriter;
++ private Options options;
++
++ private ConstantPool constant_pool;
++ private Object owner;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/BasicWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/BasicWriter.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,131 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import java.io.PrintWriter;
++
++import com.sun.tools.classfile.AttributeException;
++import com.sun.tools.classfile.ConstantPoolException;
++import com.sun.tools.classfile.DescriptorException;
++
++/*
++ * A writer similar to a PrintWriter but which does not hide exceptions.
++ * The standard print calls are line-buffered; report calls write messages directly.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class BasicWriter {
++ protected BasicWriter(Context context) {
++ lineWriter = LineWriter.instance(context);
++ out = context.get(PrintWriter.class);
++ }
++
++ protected void print(String s) {
++ lineWriter.print(s);
++ }
++
++ protected void print(Object o) {
++ lineWriter.print(o == null ? null : o.toString());
++ }
++
++ protected void println() {
++ lineWriter.println();
++ }
++
++ protected void println(String s) {
++ lineWriter.print(s);
++ lineWriter.println();
++ }
++
++ protected void println(Object o) {
++ lineWriter.print(o == null ? null : o.toString());
++ lineWriter.println();
++ }
++
++ protected String report(AttributeException e) {
++ out.println("Error: " + e.getMessage()); // i18n?
++ return "???";
++ }
++
++ protected String report(ConstantPoolException e) {
++ out.println("Error: " + e.getMessage()); // i18n?
++ return "???";
++ }
++
++ protected String report(DescriptorException e) {
++ out.println("Error: " + e.getMessage()); // i18n?
++ return "???";
++ }
++
++ protected String report(String msg) {
++ out.println("Error: " + msg); // i18n?
++ return "???";
++ }
++
++ private LineWriter lineWriter;
++ private PrintWriter out;
++
++ private static class LineWriter {
++ static LineWriter instance(Context context) {
++ LineWriter instance = context.get(LineWriter.class);
++ if (instance == null)
++ instance = new LineWriter(context);
++ return instance;
++ }
++
++ protected LineWriter(Context context) {
++ context.put(LineWriter.class, this);
++ out = context.get(PrintWriter.class);
++ buffer = new StringBuilder();
++ }
++
++ protected void print(String s) {
++ if (s == null)
++ s = "null";
++ for (int i = 0; i < s.length(); i++) {
++ char c = s.charAt(i);
++ if (c == '\n') {
++ println();
++ } else {
++ buffer.append(c);
++ }
++ }
++
++ }
++
++ protected void println() {
++ out.println(buffer);
++ buffer.setLength(0);
++ }
++
++ private PrintWriter out;
++ private StringBuilder buffer;
++ }
++}
++
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/ClassWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,488 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import java.util.Collection;
++import java.util.List;
++
++import com.sun.tools.classfile.AccessFlags;
++import com.sun.tools.classfile.Attribute;
++import com.sun.tools.classfile.Attributes;
++import com.sun.tools.classfile.ClassFile;
++import com.sun.tools.classfile.Code_attribute;
++import com.sun.tools.classfile.ConstantPool;
++import com.sun.tools.classfile.ConstantPoolException;
++import com.sun.tools.classfile.Descriptor;
++import com.sun.tools.classfile.DescriptorException;
++import com.sun.tools.classfile.Exceptions_attribute;
++import com.sun.tools.classfile.Field;
++import com.sun.tools.classfile.Method;
++import com.sun.tools.classfile.Signature;
++import com.sun.tools.classfile.Signature_attribute;
++import com.sun.tools.classfile.SourceFile_attribute;
++import com.sun.tools.classfile.Type;
++
++import static com.sun.tools.classfile.AccessFlags.*;
++
++/*
++ * The main javap class to write the contents of a class file as text.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ClassWriter extends BasicWriter {
++ static ClassWriter instance(Context context) {
++ ClassWriter instance = context.get(ClassWriter.class);
++ if (instance == null)
++ instance = new ClassWriter(context);
++ return instance;
++ }
++
++ protected ClassWriter(Context context) {
++ super(context);
++ context.put(ClassWriter.class, this);
++ options = Options.instance(context);
++ attrWriter = AttributeWriter.instance(context);
++ codeWriter = CodeWriter.instance(context);
++ constantWriter = ConstantWriter.instance(context);
++ }
++
++ ClassFile getClassFile() {
++ return classFile;
++ }
++
++ Method getMethod() {
++ return method;
++ }
++
++ public void write(ClassFile cf) {
++ classFile = cf;
++ constant_pool = classFile.constant_pool;
++
++ Attribute sfa = cf.getAttribute(Attribute.SourceFile);
++ if (sfa instanceof SourceFile_attribute) {
++ println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\"");
++ }
++
++ String name = getJavaName(classFile);
++ AccessFlags flags = cf.access_flags;
++
++ writeModifiers(flags.getClassModifiers());
++
++ if (classFile.isClass())
++ print("class ");
++ else if (classFile.isInterface())
++ print("interface ");
++
++ print(name);
++
++ Signature_attribute sigAttr = getSignature(cf.attributes);
++ if (sigAttr == null) {
++ // use info from class file header
++ if (classFile.isClass()) {
++ if (classFile.super_class != 0 ) {
++ String sn = getJavaSuperclassName(cf);
++ if (!sn.equals("java.lang.Object") || options.compat) { // BUG XXXXXXXX
++ print(" extends ");
++ print(sn);
++ }
++ }
++ }
++ for (int i = 0; i < classFile.interfaces.length; i++) {
++ print(i == 0 ? (classFile.isClass() ? " implements " : " extends ") : ",");
++ print(getJavaInterfaceName(classFile, i));
++ }
++ } else {
++ try {
++ Type t = sigAttr.getParsedSignature().getType(constant_pool);
++ // The signature parser cannot disambiguate between a
++ // FieldType and a ClassSignatureType that only contains a superclass type.
++ if (t instanceof Type.ClassSigType)
++ print(t);
++ else if (!t.isObject()) {
++ print(" extends ");
++ print(t);
++ }
++ } catch (ConstantPoolException e) {
++ print(report(e));
++ }
++ }
++
++ if (options.verbose) {
++ println();
++ attrWriter.write(cf, cf.attributes, constant_pool);
++ println(" minor version: " + cf.minor_version);
++ println(" major version: " + cf.major_version);
++ if (!options.compat)
++ writeList(" flags: ", flags.getClassFlags(), NEWLINE);
++ constantWriter.writeConstantPool();
++ println();
++ } else {
++ if (!options.compat)
++ print(" ");
++ }
++
++ println("{");
++ writeFields();
++ writeMethods();
++ println("}");
++ println();
++ }
++
++ void writeFields() {
++ for (Field f: classFile.fields) {
++ writeField(f);
++ }
++ }
++
++ void writeField(Field f) {
++ if (!options.checkAccess(f.access_flags))
++ return;
++
++ if (!(options.showLineAndLocalVariableTables
++ || options.showDisassembled
++ || options.verbose
++ || options.showInternalSignatures
++ || options.showAllAttrs)) {
++ print(" ");
++ }
++
++ AccessFlags flags = f.access_flags;
++ writeModifiers(flags.getFieldModifiers());
++ Signature_attribute sigAttr = getSignature(f.attributes);
++ if (sigAttr == null)
++ print(getFieldType(f.descriptor));
++ else {
++ try {
++ Type t = sigAttr.getParsedSignature().getType(constant_pool);
++ print(t);
++ } catch (ConstantPoolException e) {
++ // report error?
++ // fall back on non-generic descriptor
++ print(getFieldType(f.descriptor));
++ }
++ }
++ print(" ");
++ print(getFieldName(f));
++ print(";");
++ println();
++
++ if (options.showInternalSignatures)
++ println(" Signature: " + getValue(f.descriptor));
++
++ if (options.verbose && !options.compat)
++ writeList(" flags: ", flags.getFieldFlags(), NEWLINE);
++
++ if (options.showAllAttrs) {
++ for (Attribute attr: f.attributes)
++ attrWriter.write(f, attr, constant_pool);
++ println();
++ }
++
++ if (options.showDisassembled || options.showLineAndLocalVariableTables)
++ println();
++ }
++
++ void writeMethods() {
++ for (Method m: classFile.methods)
++ writeMethod(m);
++ }
++
++ void writeMethod(Method m) {
++ if (!options.checkAccess(m.access_flags))
++ return;
++
++ method = m;
++
++ if (!(options.showLineAndLocalVariableTables
++ || options.showDisassembled
++ || options.verbose
++ || options.showInternalSignatures
++ || options.showAllAttrs)) {
++ print(" ");
++ }
++
++ AccessFlags flags = m.access_flags;
++
++ Descriptor d;
++ Type.MethodType methodType;
++ List<? extends Type> methodExceptions;
++
++ Signature_attribute sigAttr = getSignature(m.attributes);
++ if (sigAttr == null) {
++ d = m.descriptor;
++ methodType = null;
++ methodExceptions = null;
++ } else {
++ Signature methodSig = sigAttr.getParsedSignature();
++ d = methodSig;
++ try {
++ methodType = (Type.MethodType) methodSig.getType(constant_pool);
++ methodExceptions = methodType.throwsTypes;
++ if (methodExceptions != null && methodExceptions.size() == 0)
++ methodExceptions = null;
++ } catch (ConstantPoolException e) {
++ // report error?
++ // fall back on standard descriptor
++ methodType = null;
++ methodExceptions = null;
++ }
++ }
++
++ writeModifiers(flags.getMethodModifiers());
++ if (methodType != null) {
++ writeListIfNotEmpty("<", methodType.typeArgTypes, "> ");
++ }
++ if (getName(m).equals("<init>")) {
++ print(getJavaName(classFile));
++ print(getParameterTypes(d, flags));
++ } else if (getName(m).equals("<clinit>")) {
++ print("{}");
++ } else {
++ print(getReturnType(d));
++ print(" ");
++ print(getName(m));
++ print(getParameterTypes(d, flags));
++ }
++
++ Attribute e_attr = m.attributes.get(Attribute.Exceptions);
++ if (e_attr != null) { // if there are generic exceptions, there must be erased exceptions
++ if (e_attr instanceof Exceptions_attribute) {
++ Exceptions_attribute exceptions = (Exceptions_attribute) e_attr;
++ if (options.compat) { // Bug XXXXXXX whitespace
++ if (!(options.showLineAndLocalVariableTables
++ || options.showDisassembled
++ || options.verbose
++ || options.showInternalSignatures
++ || options.showAllAttrs)) {
++ print(" ");
++ }
++ print(" ");
++ }
++ print(" throws ");
++ if (methodExceptions != null) { // use generic list if available
++ writeList("", methodExceptions, "");
++ } else {
++ for (int i = 0; i < exceptions.number_of_exceptions; i++) {
++ if (i > 0)
++ print(", ");
++ print(attrWriter.getJavaException(exceptions, i));
++ }
++ }
++ } else {
++ report("Unexpected or invalid value for Exceptions attribute");
++ }
++ }
++
++ print(";");
++ println();
++
++ if (options.showInternalSignatures)
++ println(" Signature: " + getValue(m.descriptor));
++
++ if (options.verbose && !options.compat)
++ writeList(" flags: ", flags.getMethodFlags(), NEWLINE);
++
++ Code_attribute code = null;
++ Attribute c_attr = m.attributes.get(Attribute.Code);
++ if (c_attr != null) {
++ if (c_attr instanceof Code_attribute)
++ code = (Code_attribute) c_attr;
++ else
++ report("Unexpected or invalid value for Code attribute");
++ }
++
++ if (options.showDisassembled && !options.showAllAttrs) {
++ if (code != null) {
++ println(" Code:");
++ codeWriter.writeInstrs(code);
++ codeWriter.writeExceptionTable(code);
++ }
++ println();
++ }
++
++ if (options.showLineAndLocalVariableTables) {
++ if (code != null)
++ attrWriter.write(code, code.attributes.get(Attribute.LineNumberTable), constant_pool);
++ println();
++ if (code != null)
++ attrWriter.write(code, code.attributes.get(Attribute.LocalVariableTable), constant_pool);
++ println();
++ println();
++ }
++
++ if (options.showAllAttrs) {
++ Attribute[] attrs = m.attributes.attrs;
++ for (Attribute attr: attrs)
++ attrWriter.write(m, attr, constant_pool);
++
++// // the following condition is to mimic old javap
++// if (!(attrs.length > 0 &&
++// attrs[attrs.length - 1] instanceof Exceptions_attribute))
++ println();
++ }
++ }
++
++ void writeModifiers(Collection<String> items) {
++ for (Object item: items) {
++ print(item);
++ print(" ");
++ }
++ }
++
++ void writeList(String prefix, Collection<?> items, String suffix) {
++ print(prefix);
++ String sep = "";
++ for (Object item: items) {
++ print(sep);
++ print(item);
++ sep = ", ";
++ }
++ print(suffix);
++ }
++
++ void writeListIfNotEmpty(String prefix, List<?> items, String suffix) {
++ if (items != null && items.size() > 0)
++ writeList(prefix, items, suffix);
++ }
++
++ Signature_attribute getSignature(Attributes attributes) {
++ if (options.compat) // javap does not recognize recent attributes
++ return null;
++ return (Signature_attribute) attributes.get(Attribute.Signature);
++ }
++
++ String adjustVarargs(AccessFlags flags, String params) {
++ if (flags.is(ACC_VARARGS) && !options.compat) {
++ int i = params.lastIndexOf("[]");
++ if (i > 0)
++ return params.substring(0, i) + "..." + params.substring(i+2);
++ }
++
++ return params;
++ }
++
++ String getJavaName(ClassFile cf) {
++ try {
++ return getJavaName(cf.getName());
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ String getJavaSuperclassName(ClassFile cf) {
++ try {
++ return getJavaName(cf.getSuperclassName());
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ String getJavaInterfaceName(ClassFile cf, int index) {
++ try {
++ return getJavaName(cf.getInterfaceName(index));
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ String getFieldType(Descriptor d) {
++ try {
++ return d.getFieldType(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ } catch (DescriptorException e) {
++ return report(e);
++ }
++ }
++
++ String getReturnType(Descriptor d) {
++ try {
++ return d.getReturnType(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ } catch (DescriptorException e) {
++ return report(e);
++ }
++ }
++
++ String getParameterTypes(Descriptor d, AccessFlags flags) {
++ try {
++ return adjustVarargs(flags, d.getParameterTypes(constant_pool));
++ } catch (ConstantPoolException e) {
++ return report(e);
++ } catch (DescriptorException e) {
++ return report(e);
++ }
++ }
++
++ String getValue(Descriptor d) {
++ try {
++ return d.getValue(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ String getFieldName(Field f) {
++ try {
++ return f.getName(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ String getName(Method m) {
++ try {
++ return m.getName(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ static String getJavaName(String name) {
++ return name.replace('/', '.');
++ }
++
++ String getSourceFile(SourceFile_attribute attr) {
++ try {
++ return attr.getSourceFile(constant_pool);
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ private Options options;
++ private AttributeWriter attrWriter;
++ private CodeWriter codeWriter;
++ private ConstantWriter constantWriter;
++ private ClassFile classFile;
++ private ConstantPool constant_pool;
++ private Method method;
++ private static final String NEWLINE = System.getProperty("line.separator", "\n");
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/CodeWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,344 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import com.sun.tools.classfile.AccessFlags;
++import com.sun.tools.classfile.Code_attribute;
++import com.sun.tools.classfile.ConstantPool;
++import com.sun.tools.classfile.ConstantPoolException;
++import com.sun.tools.classfile.DescriptorException;
++import com.sun.tools.classfile.Method;
++
++import static com.sun.tools.classfile.OpCodes.*;
++
++/*
++ * Write the contents of a Code attribute.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++class CodeWriter extends BasicWriter {
++ static CodeWriter instance(Context context) {
++ CodeWriter instance = context.get(CodeWriter.class);
++ if (instance == null)
++ instance = new CodeWriter(context);
++ return instance;
++ }
++
++ protected CodeWriter(Context context) {
++ super(context);
++ context.put(CodeWriter.class, this);
++ attrWriter = AttributeWriter.instance(context);
++ classWriter = ClassWriter.instance(context);
++ constantWriter = ConstantWriter.instance(context);
++ }
++
++ void write(Code_attribute attr, ConstantPool constant_pool) {
++ println(" Code:");
++ writeVerboseHeader(attr, constant_pool);
++ writeInstrs(attr);
++ writeExceptionTable(attr);
++ attrWriter.write(attr, attr.attributes, constant_pool);
++ }
++
++ public void writeVerboseHeader(Code_attribute attr, ConstantPool constant_pool) {
++ Method method = classWriter.getMethod();
++ String argCount;
++ try {
++ int n = method.descriptor.getParameterCount(constant_pool);
++ if (!method.access_flags.is(AccessFlags.ACC_STATIC))
++ ++n; // for 'this'
++ argCount = Integer.toString(n);
++ } catch (ConstantPoolException e) {
++ argCount = report(e);
++ } catch (DescriptorException e) {
++ argCount = report(e);
++ }
++
++ println(" Stack=" + attr.max_stack +
++ ", Locals=" + attr.max_locals +
++ ", Args_size=" + argCount);
++
++ }
++
++ public void writeInstrs(Code_attribute attr) {
++ try {
++ for (int pc = 0; pc < attr.code_length;) {
++ print(" " + pc + ":\t");
++ pc += writeInstr(attr, pc);
++ println();
++ }
++ } catch (Code_attribute.InvalidIndex e) {
++ println(report(e));
++ }
++ }
++
++ public int writeInstr(Code_attribute attr, int pc)
++ throws Code_attribute.InvalidIndex {
++ String lP = "";
++ int opcode = attr.getUnsignedByte(pc);
++ int opcode2;
++ String mnem;
++ switch (opcode) {
++ case opc_nonpriv:
++ case opc_priv: {
++ opcode2 = attr.getUnsignedByte(pc + 1);
++ mnem = opcName((opcode << 8) + opcode2);
++ if (mnem == null) {
++ mnem = opcName(opcode) + " " + opcode2;
++ }
++ print(mnem);
++ return 2;
++ }
++ case opc_wide: {
++ opcode2 = attr.getUnsignedByte(pc + 1);
++ mnem = opcName((opcode << 8) + opcode2);
++ if (mnem == null) {
++ print("bytecode " + opcode);
++ return 1;
++ }
++ print(mnem + " " + attr.getUnsignedShort(pc + 2));
++ if (opcode2 == opc_iinc) {
++ print(", " + attr.getShort(pc + 4));
++ return 6;
++ }
++ return 4;
++ }
++ }
++ mnem = opcName(opcode);
++ if (mnem == null) {
++ print("bytecode " + opcode);
++ return 1;
++ }
++ if (opcode > opc_jsr_w) {
++ print("bytecode " + opcode);
++ return 1;
++ }
++ print(opcName(opcode));
++ switch (opcode) {
++ case opc_aload:
++ case opc_astore:
++ case opc_fload:
++ case opc_fstore:
++ case opc_iload:
++ case opc_istore:
++ case opc_lload:
++ case opc_lstore:
++ case opc_dload:
++ case opc_dstore:
++ case opc_ret:
++ print("\t" + attr.getUnsignedByte(pc + 1));
++ return 2;
++ case opc_iinc:
++ print("\t" + attr.getUnsignedByte(pc + 1) + ", " + attr.getByte(pc + 2));
++ return 3;
++ case opc_tableswitch:
++ {
++ int tb = align(pc + 1);
++ int default_skip = attr.getInt(tb);
++ int low = attr.getInt(tb + 4);
++ int high = attr.getInt(tb + 8);
++ int count = high - low;
++ print("{ //" + low + " to " + high);
++ for (int i = 0; i <= count; i++) {
++ print("\n\t\t" + (i + low) + ": " + lP + (pc + attr.getInt(tb + 12 + 4 * i)) + ";");
++ }
++ print("\n\t\tdefault: " + lP + (default_skip + pc) + " }");
++ return tb - pc + 16 + count * 4;
++ }
++ case opc_lookupswitch:
++ {
++ int tb = align(pc + 1);
++ int default_skip = attr.getInt(tb);
++ int npairs = attr.getInt(tb + 4);
++ print("{ //" + npairs);
++ for (int i = 1; i <= npairs; i++) {
++ print("\n\t\t" + attr.getInt(tb + i * 8) + ": " + lP + (pc + attr.getInt(tb + 4 + i * 8)) + ";");
++ }
++ print("\n\t\tdefault: " + lP + (default_skip + pc) + " }");
++ return tb - pc + (npairs + 1) * 8;
++ }
++ case opc_newarray:
++ int type = attr.getUnsignedByte(pc + 1);
++ switch (type) {
++ case T_BOOLEAN:
++ print(" boolean");
++ break;
++ case T_BYTE:
++ print(" byte");
++ break;
++ case T_CHAR:
++ print(" char");
++ break;
++ case T_SHORT:
++ print(" short");
++ break;
++ case T_INT:
++ print(" int");
++ break;
++ case T_LONG:
++ print(" long");
++ break;
++ case T_FLOAT:
++ print(" float");
++ break;
++ case T_DOUBLE:
++ print(" double");
++ break;
++ case T_CLASS:
++ print(" class");
++ break;
++ default:
++ print(" BOGUS TYPE:" + type);
++ }
++ return 2;
++ case opc_anewarray:
++ {
++ int index = attr.getUnsignedShort(pc + 1);
++ print("\t#" + index + "; //");
++ printConstant(index);
++ return 3;
++ }
++ case opc_sipush:
++ print("\t" + attr.getShort(pc + 1));
++ return 3;
++ case opc_bipush:
++ print("\t" + attr.getByte(pc + 1));
++ return 2;
++ case opc_ldc:
++ {
++ int index = attr.getUnsignedByte(pc + 1);
++ print("\t#" + index + "; //");
++ printConstant(index);
++ return 2;
++ }
++ case opc_ldc_w:
++ case opc_ldc2_w:
++ case opc_instanceof:
++ case opc_checkcast:
++ case opc_new:
++ case opc_putstatic:
++ case opc_getstatic:
++ case opc_putfield:
++ case opc_getfield:
++ case opc_invokevirtual:
++ case opc_invokespecial:
++ case opc_invokestatic:
++ {
++ int index = attr.getUnsignedShort(pc + 1);
++ print("\t#" + index + "; //");
++ printConstant(index);
++ return 3;
++ }
++ case opc_invokeinterface:
++ {
++ int index = attr.getUnsignedShort(pc + 1);
++ int nargs = attr.getUnsignedByte(pc + 3);
++ print("\t#" + index + ", " + nargs + "; //");
++ printConstant(index);
++ return 5;
++ }
++ case opc_multianewarray:
++ {
++ int index = attr.getUnsignedShort(pc + 1);
++ int dimensions = attr.getUnsignedByte(pc + 3);
++ print("\t#" + index + ", " + dimensions + "; //");
++ printConstant(index);
++ return 4;
++ }
++ case opc_jsr:
++ case opc_goto:
++ case opc_ifeq:
++ case opc_ifge:
++ case opc_ifgt:
++ case opc_ifle:
++ case opc_iflt:
++ case opc_ifne:
++ case opc_if_icmpeq:
++ case opc_if_icmpne:
++ case opc_if_icmpge:
++ case opc_if_icmpgt:
++ case opc_if_icmple:
++ case opc_if_icmplt:
++ case opc_if_acmpeq:
++ case opc_if_acmpne:
++ case opc_ifnull:
++ case opc_ifnonnull:
++ print("\t" + lP + (pc + attr.getShort(pc + 1)));
++ return 3;
++ case opc_jsr_w:
++ case opc_goto_w:
++ print("\t" + lP + (pc + attr.getInt(pc + 1)));
++ return 5;
++ default:
++ return 1;
++ }
++ }
++
++ public void writeExceptionTable(Code_attribute attr) {
++ if (attr.exception_table_langth > 0) {
++ println(" Exception table:");
++ println(" from to target type");
++ for (int i = 0; i < attr.exception_table.length; i++) {
++ Code_attribute.Exception_data handler = attr.exception_table[i];
++ printFixedWidthInt(handler.start_pc, 6);
++ printFixedWidthInt(handler.end_pc, 6);
++ printFixedWidthInt(handler.handler_pc, 6);
++ print(" ");
++ int catch_type = handler.catch_type;
++ if (catch_type == 0) {
++ println("any");
++ } else {
++ print("Class ");
++ println(constantWriter.stringValue(catch_type));
++ println("");
++ }
++ }
++ }
++
++ }
++
++ private void printConstant(int index) {
++ constantWriter.write(index);
++ }
++
++ private void printFixedWidthInt(int n, int width) {
++ String s = String.valueOf(n);
++ for (int i = s.length(); i < width; i++)
++ print(" ");
++ print(s);
++ }
++
++ private static int align(int n) {
++ return (n + 3) & ~3;
++ }
++
++ private AttributeWriter attrWriter;
++ private ClassWriter classWriter;
++ private ConstantWriter constantWriter;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/ConstantWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,352 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import com.sun.tools.classfile.ClassFile;
++import com.sun.tools.classfile.ConstantPool;
++import com.sun.tools.classfile.ConstantPoolException;
++
++import static com.sun.tools.classfile.ConstantPool.*;
++
++/*
++ * Write a constant pool entry.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class ConstantWriter extends BasicWriter {
++ static ConstantWriter instance(Context context) {
++ ConstantWriter instance = context.get(ConstantWriter.class);
++ if (instance == null)
++ instance = new ConstantWriter(context);
++ return instance;
++ }
++
++ protected ConstantWriter(Context context) {
++ super(context);
++ context.put(ConstantWriter.class, this);
++ classWriter = ClassWriter.instance(context);
++ options = Options.instance(context);
++ }
++
++ void writeConstantPool() {
++ ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() {
++ public Integer visitClass(CONSTANT_Class_info info, Void p) {
++ println("#" + info.name_index + ";\t// " + stringValue(info));
++ return 1;
++ }
++
++ public Integer visitDouble(CONSTANT_Double_info info, Void p) {
++ println(stringValue(info) + ";");
++ return 2;
++ }
++
++ public Integer visitFieldref(CONSTANT_Fieldref_info info, Void p) {
++ println("#" + info.class_index + ".#" + info.name_and_type_index + ";\t// " + stringValue(info));
++ return 1;
++ }
++
++ public Integer visitFloat(CONSTANT_Float_info info, Void p) {
++ println(stringValue(info) + ";");
++ return 1;
++ }
++
++ public Integer visitInteger(CONSTANT_Integer_info info, Void p) {
++ println(stringValue(info) + ";");
++ return 1;
++ }
++
++ public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) {
++ println("#" + info.class_index + ".#" + info.name_and_type_index + ";\t// " + stringValue(info));
++ return 1;
++ }
++
++ public Integer visitLong(CONSTANT_Long_info info, Void p) {
++ println(stringValue(info) + ";");
++ return 2;
++ }
++
++ public Integer visitNameAndType(CONSTANT_NameAndType_info info, Void p) {
++ String tab = (options.compat ? "" : "\t"); // BUG 6622232 javap gets whitespace confused
++ println("#" + info.name_index + ":#" + info.type_index + ";" + tab + "// " + stringValue(info));
++ return 1;
++ }
++
++ public Integer visitMethodref(CONSTANT_Methodref_info info, Void p) {
++ println("#" + info.class_index + ".#" + info.name_and_type_index + ";\t// " + stringValue(info));
++ return 1;
++ }
++
++ public Integer visitString(CONSTANT_String_info info, Void p) {
++ println("#" + info.string_index + ";\t// " + stringValue(info));
++ return 1;
++ }
++
++ public Integer visitUtf8(CONSTANT_Utf8_info info, Void p) {
++ println(stringValue(info) + ";");
++ return 1;
++ }
++
++ };
++ println(" Constant pool:");
++ ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
++ int cpx = 1;
++ while (cpx < constant_pool.size()) {
++ try {
++ CPInfo cpInfo = constant_pool.get(cpx);
++ print("const #" + cpx + " = " + tagName(cpInfo.getTag()) + "\t");
++ cpx += cpInfo.accept(v, null);
++ } catch (ConstantPool.InvalidIndex ex) {
++ print("const #" + cpx); // should not happen
++ }
++ }
++ }
++
++ void write(int cpx) {
++ ClassFile classFile = classWriter.getClassFile();
++ if (cpx == 0) {
++ print("#0");
++ return;
++ }
++
++ CPInfo cpInfo;
++ try {
++ cpInfo = classFile.constant_pool.get(cpx);
++ } catch (ConstantPoolException e) {
++ print("#" + cpx);
++ return;
++ }
++
++ int tag = cpInfo.getTag();
++ switch (tag) {
++ case CONSTANT_Methodref:
++ case CONSTANT_InterfaceMethodref:
++ case CONSTANT_Fieldref:
++ // simplify references within this class
++ CPRefInfo ref = (CPRefInfo) cpInfo;
++ try {
++ if (ref.class_index == classFile.this_class)
++ cpInfo = classFile.constant_pool.get(ref.name_and_type_index);
++ } catch (ConstantPool.InvalidIndex e) {
++ // ignore, for now
++ }
++ }
++ print(tagName(tag) + " " + stringValue(cpInfo));
++ }
++
++ String tagName(int tag) {
++ switch (tag) {
++ case CONSTANT_Utf8:
++ return "Asciz";
++ case CONSTANT_Integer:
++ return "int";
++ case CONSTANT_Float:
++ return "float";
++ case CONSTANT_Long:
++ return "long";
++ case CONSTANT_Double:
++ return "double";
++ case CONSTANT_Class:
++ return "class";
++ case CONSTANT_String:
++ return "String";
++ case CONSTANT_Fieldref:
++ return "Field";
++ case CONSTANT_Methodref:
++ return "Method";
++ case CONSTANT_InterfaceMethodref:
++ return "InterfaceMethod";
++ case CONSTANT_NameAndType:
++ return "NameAndType";
++ default:
++ return "unknown tag";
++ }
++ }
++
++ String stringValue(int constant_pool_index) {
++ ClassFile classFile = classWriter.getClassFile();
++ try {
++ return stringValue(classFile.constant_pool.get(constant_pool_index));
++ } catch (ConstantPool.InvalidIndex e) {
++ return report(e);
++ }
++ }
++
++ String stringValue(CPInfo cpInfo) {
++ return stringValueVisitor.visit(cpInfo);
++ }
++
++ StringValueVisitor stringValueVisitor = new StringValueVisitor();
++
++ private class StringValueVisitor implements ConstantPool.Visitor<String, Void> {
++ public String visit(CPInfo info) {
++ return info.accept(this, null);
++ }
++
++ public String visitClass(CONSTANT_Class_info info, Void p) {
++ return getCheckedName(info);
++ }
++
++ String getCheckedName(CONSTANT_Class_info info) {
++ try {
++ return checkName(info.getName());
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public String visitDouble(CONSTANT_Double_info info, Void p) {
++ return info.value + "d";
++ }
++
++ public String visitFieldref(CONSTANT_Fieldref_info info, Void p) {
++ return visitRef(info, p);
++ }
++
++ public String visitFloat(CONSTANT_Float_info info, Void p) {
++ return info.value + "f";
++ }
++
++ public String visitInteger(CONSTANT_Integer_info info, Void p) {
++ return String.valueOf(info.value);
++ }
++
++ public String visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) {
++ return visitRef(info, p);
++ }
++
++ public String visitLong(CONSTANT_Long_info info, Void p) {
++ return info.value + "l";
++ }
++
++ public String visitNameAndType(CONSTANT_NameAndType_info info, Void p) {
++ return getCheckedName(info) + ":" + getType(info);
++ }
++
++ String getCheckedName(CONSTANT_NameAndType_info info) {
++ try {
++ return checkName(info.getName());
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ String getType(CONSTANT_NameAndType_info info) {
++ try {
++ return info.getType();
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public String visitMethodref(CONSTANT_Methodref_info info, Void p) {
++ return visitRef(info, p);
++ }
++
++ public String visitString(CONSTANT_String_info info, Void p) {
++ try {
++ ClassFile classFile = classWriter.getClassFile();
++ int string_index = info.string_index;
++ return stringValue(classFile.constant_pool.getUTF8Info(string_index));
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
++ public String visitUtf8(CONSTANT_Utf8_info info, Void p) {
++ String s = info.value;
++ StringBuilder sb = new StringBuilder();
++ for (int i = 0; i < s.length(); i++) {
++ char c = s.charAt(i);
++ switch (c) {
++ case '\t':
++ sb.append('\\').append('t');
++ break;
++ case '\n':
++ sb.append('\\').append('n');
++ break;
++ case '\r':
++ sb.append('\\').append('r');
++ break;
++ case '\"':
++ sb.append('\\').append('\"');
++ break;
++ default:
++ sb.append(c);
++ }
++ }
++ return sb.toString();
++ }
++
++ String visitRef(CPRefInfo info, Void p) {
++ String cn = getCheckedClassName(info);
++ String nat;
++ try {
++ nat = stringValue(info.getNameAndTypeInfo());
++ } catch (ConstantPoolException e) {
++ nat = report(e);
++ }
++ return cn + "." + nat;
++ }
++
++ String getCheckedClassName(CPRefInfo info) {
++ try {
++ return checkName(info.getClassName());
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++ }
++
++
++ /* If name is a valid binary name, return it; otherwise quote it. */
++ private static String checkName(String name) {
++ if (name == null)
++ return "null";
++
++ int len = name.length();
++ if (len == 0)
++ return "\"\"";
++
++ int cc = '/';
++ int cp;
++ for (int k = 0; k < len; k += Character.charCount(cp)) {
++ cp = name.codePointAt(k);
++ if ((cc == '/' && !Character.isJavaIdentifierStart(cp))
++ || (cp != '/' && !Character.isJavaIdentifierPart(cp))) {
++ return "\"" + name + "\"";
++ }
++ cc = cp;
++ }
++
++ return name;
++ }
++
++ private ClassWriter classWriter;
++ private Options options;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/Context.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/Context.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,55 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import java.util.HashMap;
++import java.util.Map;
++
++/*
++ * Class from which to put/get shared resources.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Context {
++ public Context() {
++ map = new HashMap<Class<?>, Object>();
++ }
++
++ @SuppressWarnings("unchecked")
++ public <T> T get(Class<T> key) {
++ return (T) map.get(key);
++ }
++
++ @SuppressWarnings("unchecked")
++ public <T> T put(Class<T> key, T value) {
++ return (T) map.put(key, value);
++ }
++
++ Map<Class<?>, Object> map;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/DisassemblerTool.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,150 @@
++/*
++ * Copyright 2005-2006 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 com.sun.tools.javap; //javax.tools;
++
++import java.io.Writer;
++import java.nio.charset.Charset;
++import java.util.Locale;
++import java.util.concurrent.Callable;
++import javax.tools.DiagnosticListener;
++import javax.tools.JavaFileManager;
++import javax.tools.JavaFileObject;
++import javax.tools.OptionChecker;
++import javax.tools.StandardJavaFileManager;
++import javax.tools.Tool;
++
++/**
++ * This class is intended to be put in javax.tools.
++ *
++ * @see DiagnosticListener
++ * @see Diagnostic
++ * @see JavaFileManager
++ * @since 1.6
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public interface DisassemblerTool extends Tool, OptionChecker {
++
++ /**
++ * Creates a future for a disassembly task with the given
++ * components and arguments. The task might not have
++ * completed as described in the DissemblerTask interface.
++ *
++ * <p>If a file manager is provided, it must be able to handle all
++ * locations defined in {@link StandardLocation}.
++ *
++ * @param out a Writer for additional output from the compiler;
++ * use {@code System.err} if {@code null}
++ * @param fileManager a file manager; if {@code null} use the
++ * compiler's standard filemanager
++ * @param diagnosticListener a diagnostic listener; if {@code
++ * null} use the compiler's default method for reporting
++ * diagnostics
++ * @param options compiler options, {@code null} means no options
++ * @param classes class names (for annotation processing), {@code
++ * null} means no class names
++ * @param compilationUnits the compilation units to compile, {@code
++ * null} means no compilation units
++ * @return an object representing the compilation
++ * @throws RuntimeException if an unrecoverable error
++ * occurred in a user supplied component. The
++ * {@linkplain Throwable#getCause() cause} will be the error in
++ * user code.
++ * @throws IllegalArgumentException if any of the given
++ * compilation units are of other kind than
++ * {@linkplain JavaFileObject.Kind#SOURCE source}
++ */
++ DisassemblerTask getTask(Writer out,
++ JavaFileManager fileManager,
++ DiagnosticListener<? super JavaFileObject> diagnosticListener,
++ Iterable<String> options,
++ Iterable<String> classes);
++
++ /**
++ * Gets a new instance of the standard file manager implementation
++ * for this tool. The file manager will use the given diagnostic
++ * listener for producing any non-fatal diagnostics. Fatal errors
++ * will be signalled with the appropriate exceptions.
++ *
++ * <p>The standard file manager will be automatically reopened if
++ * it is accessed after calls to {@code flush} or {@code close}.
++ * The standard file manager must be usable with other tools.
++ *
++ * @param diagnosticListener a diagnostic listener for non-fatal
++ * diagnostics; if {@code null} use the compiler's default method
++ * for reporting diagnostics
++ * @param locale the locale to apply when formatting diagnostics;
++ * {@code null} means the {@linkplain Locale#getDefault() default locale}.
++ * @param charset the character set used for decoding bytes; if
++ * {@code null} use the platform default
++ * @return the standard file manager
++ */
++ StandardJavaFileManager getStandardFileManager(
++ DiagnosticListener<? super JavaFileObject> diagnosticListener,
++ Locale locale,
++ Charset charset);
++
++ /**
++ * Interface representing a future for a disassembly task. The
++ * task has not yet started. To start the task, call
++ * the {@linkplain #call call} method.
++ *
++ * <p>Before calling the call method, additional aspects of the
++ * task can be configured, for example, by calling the
++ * {@linkplain #setLocale setLocale} method.
++ */
++ interface DisassemblerTask extends Callable<Boolean> {
++
++ /**
++ * Set the locale to be applied when formatting diagnostics and
++ * other localized data.
++ *
++ * @param locale the locale to apply; {@code null} means apply no
++ * locale
++ * @throws IllegalStateException if the task has started
++ */
++ void setLocale(Locale locale);
++
++ /**
++ * Performs this compilation task. The compilation may only
++ * be performed once. Subsequent calls to this method throw
++ * IllegalStateException.
++ *
++ * @return true if and only all the files compiled without errors;
++ * false otherwise
++ *
++ * @throws RuntimeException if an unrecoverable error occurred
++ * in a user-supplied component. The
++ * {@linkplain Throwable#getCause() cause} will be the error
++ * in user code.
++ * @throws IllegalStateException if called more than once
++ */
++ Boolean call();
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/InternalError.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/InternalError.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,46 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++/**
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class InternalError extends Error {
++ InternalError(Throwable t, Object... args) {
++ super("Internal error", t);
++ this.args = args;
++ }
++
++ InternalError(Object... args) {
++ super("Internal error");
++ this.args = args;
++ }
++
++ public final Object[] args;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/JavapFileManager.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/JavapFileManager.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,86 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import java.io.File;
++import java.io.PrintWriter;
++import java.nio.charset.Charset;
++import javax.tools.Diagnostic;
++import javax.tools.DiagnosticListener;
++import javax.tools.JavaFileObject;
++
++import com.sun.tools.javac.file.JavacFileManager;
++import com.sun.tools.javac.util.Context;
++import com.sun.tools.javac.util.JCDiagnostic;
++
++/**
++ * javap's implementation of JavaFileManager.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++class JavapFileManager extends JavacFileManager {
++ private JavapFileManager(Context context, Charset charset) {
++ super(context, true, charset);
++ }
++
++ static JavapFileManager create(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log, Options options) {
++ Context javac_context = new Context();
++
++ if (dl != null) {
++ // Workaround bug 6625520: javac handles missing entries on classpath badly
++ // Ignore spurious errors for missing files
++ DiagnosticListener<JavaFileObject> wrapper = new DiagnosticListener<JavaFileObject>() {
++ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
++ if (diagnostic instanceof JCDiagnostic) {
++ JCDiagnostic jcd = (JCDiagnostic) diagnostic;
++ if (jcd.getCode().equals("compiler.err.error.reading.file")) {
++ Object[] args = jcd.getArgs();
++ if (args.length > 0 && args[0] != null && args[0].toString().length() > 0) {
++ File f = new File(args[0].toString());
++ if (!f.exists())
++ return;
++ }
++ }
++
++ }
++ dl.report(diagnostic);
++ }
++ };
++ javac_context.put(DiagnosticListener.class, wrapper);
++ }
++
++ javac_context.put(com.sun.tools.javac.util.Log.outKey, log);
++
++ return new JavapFileManager(javac_context, null);
++ }
++
++ void setIgnoreSymbolFile(boolean b) {
++ ignoreSymbolFile = b;
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/JavapTask.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,624 @@
++/*
++ * Copyright 2007 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-15301 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 com.sun.tools.javap;
++
++import java.io.EOFException;
++import java.io.FileNotFoundException;
++import java.io.IOException;
++import java.io.OutputStream;
++import java.io.PrintWriter;
++import java.io.StringWriter;
++import java.io.Writer;
++import java.text.MessageFormat;
++import java.util.ArrayList;
++import java.util.Arrays;
++import java.util.HashMap;
++import java.util.Iterator;
++import java.util.List;
++import java.util.Locale;
++import java.util.Map;
++import java.util.MissingResourceException;
++import java.util.ResourceBundle;
++
++import javax.tools.Diagnostic;
++import javax.tools.DiagnosticListener;
++import javax.tools.JavaFileManager;
++import javax.tools.JavaFileObject;
++import javax.tools.StandardJavaFileManager;
++import javax.tools.StandardLocation;
++
++import com.sun.tools.classfile.*;
++
++/**
++ * "Main" class for javap, normally accessed from the command line
++ * via Main, or from JSR199 via DisassemblerTool.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class JavapTask implements DisassemblerTool.DisassemblerTask {
++ public class BadArgs extends Exception {
++ static final long serialVersionUID = 8765093759964640721L;
++ BadArgs(String key, Object... args) {
++ super(JavapTask.this.getMessage(key, args));
++ this.key = key;
++ this.args = args;
++ }
++
++ BadArgs showUsage(boolean b) {
++ showUsage = b;
++ return this;
++ }
++
++ final String key;
++ final Object[] args;
++ boolean showUsage;
++ }
++
++ static abstract class Option {
++ Option(boolean hasArg, String... aliases) {
++ this.hasArg = hasArg;
++ this.aliases = aliases;
++ }
++
++ boolean matches(String opt) {
++ for (String a: aliases) {
++ if (a.equals(opt))
++ return true;
++ }
++ return false;
++ }
++
++ boolean ignoreRest() {
++ return false;
++ }
++
++ abstract void process(JavapTask task, String opt, String arg) throws BadArgs;
++
++ final boolean hasArg;
++ final String[] aliases;
++ }
++
++ static Option[] recognizedOptions = {
++
++ new Option(false, "-help", "--help", "-?") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.help = true;
++ }
++ },
++
++ new Option(false, "-version") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.version = true;
++ }
++ },
++
++ new Option(false, "-fullversion") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.fullVersion = true;
++ }
++ },
++
++ new Option(false, "-v", "-verbose", "-all") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.verbose = true;
++ task.options.showFlags = true;
++ task.options.showAllAttrs = true;
++ }
++ },
++
++ new Option(false, "-l") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.showLineAndLocalVariableTables = true;
++ }
++ },
++
++ new Option(false, "-public") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.showAccess = AccessFlags.ACC_PUBLIC;
++ }
++ },
++
++ new Option(false, "-protected") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.showAccess = AccessFlags.ACC_PROTECTED;
++ }
++ },
++
++ new Option(false, "-package") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.showAccess = 0;
++ }
++ },
++
++ new Option(false, "-p", "-private") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.showAccess = AccessFlags.ACC_PRIVATE;
++ }
++ },
++
++ new Option(false, "-c") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.showDisassembled = true;
++ }
++ },
++
++ new Option(false, "-s") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.showInternalSignatures = true;
++ }
++ },
++
++// new Option(false, "-all") {
++// void process(JavapTask task, String opt, String arg) {
++// task.options.showAllAttrs = true;
++// }
++// },
++
++ new Option(false, "-h") {
++ void process(JavapTask task, String opt, String arg) throws BadArgs {
++ throw task.new BadArgs("err.h.not.supported");
++ }
++ },
++
++ new Option(false, "-verify", "-verify-verbose") {
++ void process(JavapTask task, String opt, String arg) throws BadArgs {
++ throw task.new BadArgs("err.verify.not.supported");
++ }
++ },
++
++ new Option(false, "-Xold") {
++ void process(JavapTask task, String opt, String arg) throws BadArgs {
++ // -Xold is only supported as first arg when invoked from
++ // command line; this is handled in Main,main
++ throw task.new BadArgs("err.Xold.not.supported.here");
++ }
++ },
++
++ new Option(false, "-Xnew") {
++ void process(JavapTask task, String opt, String arg) throws BadArgs {
++ // ignore: this _is_ the new version
++ }
++ },
++
++ new Option(false, "-XDcompat") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.compat = true;
++ }
++ },
++
++ new Option(false, "-XDjsr277") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.jsr277 = true;
++ }
++ },
++
++ new Option(false, "-XDignore.symbol.file") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.ignoreSymbolFile = true;
++ }
++ }
++
++ };
++
++ JavapTask() {
++ context = new Context();
++ options = Options.instance(context);
++ }
++
++ JavapTask(Writer out,
++ JavaFileManager fileManager,
++ DiagnosticListener<? super JavaFileObject> diagnosticListener,
++ Iterable<String> options,
++ Iterable<String> classes) {
++ this();
++ this.log = getPrintWriterForWriter(out);
++ this.fileManager = fileManager;
++ this.diagnosticListener = diagnosticListener;
++
++ try {
++ handleOptions(options, false);
++ } catch (BadArgs e) {
++ throw new IllegalArgumentException(e.getMessage());
++ }
++
++ this.classes = new ArrayList<String>();
++ for (String classname: classes) {
++ classname.getClass(); // null-check
++ this.classes.add(classname);
++ }
++ }
++
++ public void setLocale(Locale locale) {
++ if (locale == null)
++ locale = Locale.getDefault();
++ task_locale = locale;
++ }
++
++ public void setLog(PrintWriter log) {
++ this.log = log;
++ }
++
++ public void setLog(OutputStream s) {
++ setLog(getPrintWriterForStream(s));
++ }
++
++ private static PrintWriter getPrintWriterForStream(OutputStream s) {
++ return new PrintWriter(s, true);
++ }
++
++ private static PrintWriter getPrintWriterForWriter(Writer w) {
++ if (w == null)
++ return getPrintWriterForStream(null);
++ else if (w instanceof PrintWriter)
++ return (PrintWriter) w;
++ else
++ return new PrintWriter(w, true);
++ }
++
++ public void setDiagnosticListener(DiagnosticListener<? super JavaFileObject> dl) {
++ diagnosticListener = dl;
++ }
++
++ public void setDiagnosticListener(OutputStream s) {
++ setDiagnosticListener(getDiagnosticListenerForStream(s));
++ }
++
++ private DiagnosticListener<JavaFileObject> getDiagnosticListenerForStream(OutputStream s) {
++ return getDiagnosticListenerForWriter(getPrintWriterForStream(s));
++ }
++
++ private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) {
++ final PrintWriter pw = getPrintWriterForWriter(w);
++ return new DiagnosticListener<JavaFileObject> () {
++ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
++ if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
++ pw.print(getMessage("err.prefix"));
++ pw.print(" ");
++ }
++ pw.println(diagnostic.getMessage(null));
++ }
++ };
++ }
++
++ int run(String[] args) {
++ try {
++ handleOptions(args);
++ boolean ok = run();
++ return ok ? 0 : 1;
++ } catch (BadArgs e) {
++ diagnosticListener.report(createDiagnostic(e.key, e.args));
++ return 1;
++ } catch (InternalError e) {
++ Object[] e_args;
++ if (e.getCause() == null)
++ e_args = e.args;
++ else {
++ e_args = new Object[e.args.length + 1];
++ e_args[0] = e.getCause();
++ System.arraycopy(e.args, 0, e_args, 1, e.args.length);
++ }
++ diagnosticListener.report(createDiagnostic("err.internal.error", e_args));
++ return 1;
++ } finally {
++ log.flush();
++ }
++ }
++
++ public void handleOptions(String[] args) throws BadArgs {
++ handleOptions(Arrays.asList(args), true);
++ }
++
++ private void handleOptions(Iterable<String> args, boolean allowClasses) throws BadArgs {
++ if (log == null) {
++ log = getPrintWriterForStream(System.out);
++ if (diagnosticListener == null)
++ diagnosticListener = getDiagnosticListenerForStream(System.err);
++ } else {
++ if (diagnosticListener == null)
++ diagnosticListener = getDiagnosticListenerForWriter(log);
++ }
++
++
++ if (fileManager == null)
++ fileManager = getDefaultFileManager(diagnosticListener, log);
++
++ Iterator<String> iter = args.iterator();
++ if (!iter.hasNext())
++ options.help = true;
++
++ while (iter.hasNext()) {
++ String arg = iter.next();
++ if (arg.startsWith("-"))
++ handleOption(arg, iter);
++ else if (allowClasses) {
++ if (classes == null)
++ classes = new ArrayList<String>();
++ classes.add(arg);
++ while (iter.hasNext())
++ classes.add(iter.next());
++ } else
++ throw new BadArgs("err.unknown.option", arg).showUsage(true);
++ }
++
++ if (options.ignoreSymbolFile && fileManager instanceof JavapFileManager)
++ ((JavapFileManager) fileManager).setIgnoreSymbolFile(true);
++
++ if ((classes == null || classes.size() == 0) &&
++ !(options.help || options.version || options.fullVersion)) {
++ throw new BadArgs("err.no.classes.specified");
++ }
++ }
++
++ private void handleOption(String name, Iterator<String> rest) throws BadArgs {
++ for (Option o: recognizedOptions) {
++ if (o.matches(name)) {
++ if (o.hasArg) {
++ if (rest.hasNext())
++ o.process(this, name, rest.next());
++ else
++ throw new BadArgs("err.missing.arg", name).showUsage(true);
++ } else
++ o.process(this, name, null);
++
++ if (o.ignoreRest()) {
++ while (rest.hasNext())
++ rest.next();
++ }
++ return;
++ }
++ }
++
++ if (fileManager.handleOption(name, rest))
++ return;
++
++ throw new BadArgs("err.unknown.option", name).showUsage(true);
++ }
++
++ public Boolean call() {
++ return run();
++ }
++
++ public boolean run() {
++ if (options.help)
++ showHelp();
++
++ if (options.version || options.fullVersion)
++ showVersion(options.fullVersion);
++
++ if (classes == null || classes.size() == 0)
++ return true;
++
++ context.put(PrintWriter.class, log);
++ ClassWriter classWriter = ClassWriter.instance(context);
++
++ boolean ok = true;
++
++ for (String className: classes) {
++ JavaFileObject fo;
++ try {
++ if (className.endsWith(".class")) {
++ if (fileManager instanceof StandardJavaFileManager) {
++ StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
++ fo = sfm.getJavaFileObjects(className).iterator().next();
++ } else {
++ diagnosticListener.report(createDiagnostic("err.not.standard.file.manager", className));
++ ok = false;
++ continue;
++ }
++ } else {
++ fo = getClassFileObject(className);
++ if (fo == null) {
++ // see if it is an inner class, by replacing dots to $, starting from the right
++ String cn = className;
++ int lastDot;
++ while (fo == null && (lastDot = cn.lastIndexOf(".")) != -1) {
++ cn = cn.substring(0, lastDot) + "$" + cn.substring(lastDot + 1);
++ fo = getClassFileObject(cn);
++ }
++ }
++ if (fo == null) {
++ diagnosticListener.report(createDiagnostic("err.class.not.found", className));
++ ok = false;
++ continue;
++ }
++ }
++ Attribute.Factory attributeFactory = new Attribute.Factory();
++ attributeFactory.setCompat(options.compat);
++ attributeFactory.setJSR277(options.jsr277);
++ ClassFile cf = ClassFile.read(fo.openInputStream(), attributeFactory);
++ classWriter.write(cf);
++ } catch (ConstantPoolException e) {
++ diagnosticListener.report(createDiagnostic("err.bad.constant.pool", className, e.getLocalizedMessage()));
++ ok = false;
++ } catch (EOFException e) {
++ diagnosticListener.report(createDiagnostic("err.end.of.file", className));
++ ok = false;
++ } catch (FileNotFoundException e) {
++ diagnosticListener.report(createDiagnostic("err.file.not.found", e.getLocalizedMessage()));
++ ok = false;
++ } catch (IOException e) {
++ //e.printStackTrace();
++ Object msg = e.getLocalizedMessage();
++ if (msg == null)
++ msg = e;
++ diagnosticListener.report(createDiagnostic("err.ioerror", className, msg));
++ ok = false;
++ } catch (Throwable t) {
++ StringWriter sw = new StringWriter();
++ PrintWriter pw = new PrintWriter(sw);
++ t.printStackTrace(pw);
++ pw.close();
++ diagnosticListener.report(createDiagnostic("err.crash", t.toString(), sw.toString()));
++ }
++ }
++
++ return ok;
++ }
++
++ private JavaFileManager getDefaultFileManager(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) {
++ return JavapFileManager.create(dl, log, options);
++ }
++
++ private JavaFileObject getClassFileObject(String className) throws IOException {
++ JavaFileObject fo;
++ fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS);
++ if (fo == null)
++ fo = fileManager.getJavaFileForInput(StandardLocation.CLASS_PATH, className, JavaFileObject.Kind.CLASS);
++ return fo;
++ }
++
++ private void showHelp() {
++ log.println(getMessage("main.usage", progname));
++ for (Option o: recognizedOptions) {
++ String name = o.aliases[0].substring(1); // there must always be at least one name
++ if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify"))
++ continue;
++ log.println(getMessage("main.opt." + name));
++ }
++ String[] fmOptions = { "-classpath", "-bootclasspath" };
++ for (String o: fmOptions) {
++ if (fileManager.isSupportedOption(o) == -1)
++ continue;
++ String name = o.substring(1);
++ log.println(getMessage("main.opt." + name));
++ }
++
++ }
++
++ private void showVersion(boolean full) {
++ log.println(version(full ? "full" : "release"));
++ }
++
++ private static final String versionRBName = "com.sun.tools.javap.resources.version";
++ private static ResourceBundle versionRB;
++
++ private String version(String key) {
++ // key=version: mm.nn.oo[-milestone]
++ // key=full: mm.mm.oo[-milestone]-build
++ if (versionRB == null) {
++ try {
++ versionRB = ResourceBundle.getBundle(versionRBName);
++ } catch (MissingResourceException e) {
++ return getMessage("version.resource.missing", System.getProperty("java.version"));
++ }
++ }
++ try {
++ return versionRB.getString(key);
++ }
++ catch (MissingResourceException e) {
++ return getMessage("version.unknown", System.getProperty("java.version"));
++ }
++ }
++
++ private Diagnostic<JavaFileObject> createDiagnostic(final String key, final Object... args) {
++ return new Diagnostic<JavaFileObject>() {
++ public Kind getKind() {
++ return Diagnostic.Kind.ERROR;
++ }
++
++ public JavaFileObject getSource() {
++ return null;
++ }
++
++ public long getPosition() {
++ return Diagnostic.NOPOS;
++ }
++
++ public long getStartPosition() {
++ return Diagnostic.NOPOS;
++ }
++
++ public long getEndPosition() {
++ return Diagnostic.NOPOS;
++ }
++
++ public long getLineNumber() {
++ return Diagnostic.NOPOS;
++ }
++
++ public long getColumnNumber() {
++ return Diagnostic.NOPOS;
++ }
++
++ public String getCode() {
++ return key;
++ }
++
++ public String getMessage(Locale locale) {
++ return JavapTask.this.getMessage(locale, key, args);
++ }
++
++ };
++
++ }
++
++ private String getMessage(String key, Object... args) {
++ return getMessage(task_locale, key, args);
++ }
++
++ private String getMessage(Locale locale, String key, Object... args) {
++ if (bundles == null) {
++ // could make this a HashMap<Locale,SoftReference<ResourceBundle>>
++ // and for efficiency, keep a hard reference to the bundle for the task
++ // locale
++ bundles = new HashMap<Locale, ResourceBundle>();
++ }
++
++ if (locale == null)
++ locale = Locale.getDefault();
++
++ ResourceBundle b = bundles.get(locale);
++ if (b == null) {
++ try {
++ b = ResourceBundle.getBundle("com.sun.tools.javap.resources.javap", locale);
++ bundles.put(locale, b);
++ } catch (MissingResourceException e) {
++ throw new InternalError("Cannot find javap resource bundle for locale " + locale);
++ }
++ }
++
++ try {
++ return MessageFormat.format(b.getString(key), args);
++ } catch (MissingResourceException e) {
++ throw new InternalError(e, key);
++ }
++ }
++
++ Context context;
++ JavaFileManager fileManager;
++ PrintWriter log;
++ DiagnosticListener<? super JavaFileObject> diagnosticListener;
++ List<String> classes;
++ Options options;
++ //ResourceBundle bundle;
++ Locale task_locale;
++ Map<Locale, ResourceBundle> bundles;
++
++ private static final String progname = "javap";
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/Main.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/Main.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,68 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import java.io.PrintWriter;
++
++/**
++ * Main entry point.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Main {
++ /**
++ * Main entry point for the launcher.
++ * Note: This method calls System.exit.
++ * @param args command line arguments
++ */
++ public static void main(String[] args) {
++ if (args.length >= 1 && args[0].equals("-Xold")) {
++ String[] nArgs = new String[args.length - 1];
++ System.arraycopy(args, 1, nArgs, 0, nArgs.length);
++ sun.tools.javap.Main.main(args); // calls System.exit
++ System.exit(1);
++ }
++
++ JavapTask t = new JavapTask();
++ int rc = t.run(args);
++ System.exit(rc);
++ }
++
++ /**
++ * Entry point that does <i>not</i> call System.exit.
++ * @param args command line arguments
++ * @param out output stream
++ * @return an exit code. 0 means success, non-zero means an error occurred.
++ */
++ public static int run(String[] args, PrintWriter out) {
++ JavapTask t = new JavapTask();
++ t.setLog(out);
++ return t.run(args);
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/Options.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/Options.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,84 @@
++/*
++ * Copyright 2007 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 com.sun.tools.javap;
++
++import com.sun.tools.classfile.AccessFlags;
++
++/*
++ * Provides access to javap's options, set via the command line
++ * or JSR 199 API.
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class Options {
++ public static Options instance(Context context) {
++ Options instance = context.get(Options.class);
++ if (instance == null)
++ instance = new Options(context);
++ return instance;
++ }
++
++ protected Options(Context context) {
++ context.put(Options.class, this);
++ }
++
++ /**
++ * Checks access of class, field or method.
++ */
++ public boolean checkAccess(AccessFlags flags){
++
++ boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
++ boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
++ boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
++ boolean isPackage = !(isPublic || isProtected || isPrivate);
++
++ if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage))
++ return false;
++ else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage))
++ return false;
++ else if ((showAccess == 0) && (isPrivate))
++ return false;
++ else
++ return true;
++ }
++
++ public boolean help;
++ public boolean verbose;
++ public boolean version;
++ public boolean fullVersion;
++ public boolean showFlags;
++ public boolean showLineAndLocalVariableTables;
++ public int showAccess;
++ public boolean showDisassembled;
++ public boolean showInternalSignatures;
++ public boolean showAllAttrs;
++
++ public boolean compat; // bug-for-bug compatibility mode with old javap
++ public boolean jsr277;
++ public boolean ignoreSymbolFile; // file manager should ignore ct.sym
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/overview.html
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/overview.html Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,10 @@
++<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
++<html>
++ <head>
++ <title>javap: class file disassembler</title>
++ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
++ </head>
++ <body>
++ Javap is a class file disassembler.
++ </body>
++</html>
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/package.html
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/package.html Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,10 @@
++<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
++<html>
++ <head>
++ <title></title>
++ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
++ </head>
++ <body>
++ Classes to dump class files in text format.
++ </body>
++</html>
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/resources/javap.properties
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,62 @@
++
++err.prefix=Error:
++
++err.bad.constant.pool=error while reading constant pool for {0}: {1}
++err.class.not.found=class not found: {0}
++err.crash=A serious internal error has occurred: {0}\nPlease file a bug report, and include the following information:\n{1}
++err.end.of.file=unexpected end of file while reading {0}
++err.file.not.found=file not found: {0}
++err.h.not.supported=-h is no longer available - use the 'javah' program
++err.internal.error=internal error: {0} {1} {2}
++err.ioerror=IO error reading {0}: {1}
++err.missing.arg=no value given for {0}
++err.no.classes.specified=no classes specified
++err.not.standard.file.manager=can only specify class files when using a standard file manager
++err.unknown.option=unknown option: {0}
++err.verify.not.supported=-verify not supported
++err.Xold.not.supported.here=-Xold must be given as the first option
++
++main.usage=\
++Usage: {0} <options> <classes>\n\
++where possible options include:
++
++
++main.opt.help=\
++\ -help --help -? Print this usage message
++
++main.opt.version=\
++\ -version Version information
++
++main.opt.v=\
++\ -v -verbose Print additional information
++
++main.opt.l=\
++\ -l Print line number and local variable tables
++
++main.opt.public=\
++\ -public Show only public classes and members
++
++main.opt.protected=\
++\ -protected Show protected/public classes and members
++
++main.opt.package=\
++\ -package Show package/protected/public classes\n\
++\ and members (default)
++
++main.opt.p=\
++\ -p -private Show all classes and members
++
++main.opt.c=\
++\ -c Disassemble the code
++
++main.opt.s=\
++\ -s Print internal type signatures
++
++main.opt.classpath=\
++\ -classpath <path> Specify where to find user class files
++
++main.opt.bootclasspath=\
++\ -bootclasspath <path> Override location of bootstrap class files
++
++
++
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/com/sun/tools/javap/resources/version.properties-template
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/resources/version.properties-template Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,28 @@
++#
++# Copyright 2007-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.
++#
++
++jdk=$(JDK_VERSION)
++full=$(FULL_VERSION)
++release=$(RELEASE)
+diff -r 8e38c8fe0a0b -r bfd7bb421825 src/share/classes/sun/tools/javap/Main.java
+--- langtools/src/share/classes/sun/tools/javap/Main.java Fri Oct 04 12:22:34 2013 -0400
++++ langtools/src/share/classes/sun/tools/javap/Main.java Tue Oct 22 01:03:49 2013 +0100
+@@ -49,6 +49,12 @@
+ }
+
+ public static void main(String argv[]) {
++ // unless first arg is -Xold, use new javap
++ if (!(argv.length >= 1 && argv[0].equals("-Xold"))) {
++ com.sun.tools.javap.Main.main(argv);
++ return;
++ }
++
+ entry(argv);
+ if (errorOccurred) {
+ System.exit(1);
+@@ -178,6 +184,8 @@
+ }
+ } else if (arg.equals("-all")) {
+ env.showallAttr = true;
++ } else if (arg.equals("-Xold")) {
++ // ignore: this is old javap
+ } else {
+ error("invalid flag: " + arg);
+ usage();
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/4870651/T4870651.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/4870651/T4870651.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,81 @@
++/*
++ * 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 4870651
++ * @summary javap should recognize generics, varargs, enum
++ * @build T4870651 Test
++ * @run main T4870651
++ */
++
++import java.io.*;
++
++public class T4870651 {
++ public static void main(String[] args) throws Exception {
++ new T4870651().run();
++ }
++
++ public void run() throws IOException {
++ verify("Test",
++ "class Test<T, E extends java.lang.Exception & java.lang.Comparable<T>, U extends java.lang.Comparable>",
++ "v1(java.lang.String...)");
++
++ verify("Test$Enum",
++ "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM",
++ "flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL, ACC_ENUM");
++
++ if (errors > 0)
++ throw new Error(errors + " found.");
++ }
++
++ String javap(String className) {
++ String testClasses = System.getProperty("test.classes", ".");
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ String[] args = { "-classpath", testClasses, "-v", className };
++ int rc = com.sun.tools.javap.Main.run(args, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ String output = sw.toString();
++ System.out.println("class " + className);
++ System.out.println(output);
++ return output;
++ }
++
++ void verify(String className, String... expects) {
++ String output = javap(className);
++ for (String expect: expects) {
++ if (output.indexOf(expect)< 0)
++ error(expect + " not found");
++ }
++ }
++
++ void error(String msg) {
++ System.err.println(msg);
++ errors++;
++ }
++
++ int errors;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/4870651/Test.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/4870651/Test.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,76 @@
++/*
++ * 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.
++ */
++
++import java.util.*;
++
++abstract class Test<T,E extends Exception & Comparable<T>,U extends Comparable> {
++ T t;
++
++ Test(T t) { }
++ <G> Test(G g, int i) { }
++
++ Test(String... args) { }
++ Test(int i, Object[]... args) { }
++ abstract void v1(String... args);
++ abstract void v2(int i, String[]... args);
++
++ abstract void a1(int x);
++ abstract void a2(int[] x);
++ abstract void a3(T x);
++ abstract void a4(T[] x);
++
++ abstract int r1();
++ abstract int[] r2();
++ abstract T r3();
++ abstract T[] r4();
++
++ abstract <G> void ga1(int x);
++ abstract <G> void ga2(int[] x);
++ abstract <G> void ga3(G x);
++ abstract <G> void ga4(G[] x);
++
++ abstract <G> int gr1();
++ abstract <G> int[] gr2();
++ abstract <G> G gr3();
++ abstract <G> G[] gr4();
++
++ abstract <G extends Exception> void ge() throws G;
++
++ abstract void w(List<?> l);
++ abstract void we(List<? extends T> l);
++ abstract void ws(List<? super T> l);
++
++ abstract void t1() throws Error;
++ abstract void t2() throws E;
++ abstract void t3() throws E,Error;
++
++ abstract void i1(Test<T, E, Comparable> x);
++ abstract void i3(Test<T, E, Comparable>.Inner<String> x);
++
++ class Inner<Q> { }
++ class Inner2<Q> extends Inner<Q> { }
++
++ class Simple { }
++
++ enum Enum { e1, e2, e3 }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/ListTest.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/ListTest.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,147 @@
++/*
++ * 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.
++ */
++
++import java.io.*;
++import java.util.*;
++import javax.tools.*;
++
++/*
++ * @test
++ * @bug 6439940
++ * @summary Cleanup javap implementation
++ * @run main/othervm ListTest
++ */
++public class ListTest {
++ public static void main(String[] args) throws Exception {
++ new ListTest().run();
++ }
++
++ ListTest() {
++ String v = System.getProperty("view.cmd");
++ // v = "/opt/teamware/7.7/bin/filemerge -r";
++ if (v != null) {
++ viewResults = true;
++ viewCmd = Arrays.asList(v.split(" +"));
++ }
++ }
++
++ void run() throws Exception {
++ StandardLocation[] locs = new StandardLocation[] {
++ StandardLocation.PLATFORM_CLASS_PATH,
++ StandardLocation.CLASS_PATH,
++ };
++
++ int count = 0;
++ int pass = 0;
++ for (StandardLocation loc: locs) {
++ for (String testClassName: list(loc)) {
++ count++;
++ if (test(testClassName))
++ pass++;
++ }
++ }
++
++ if (pass < count)
++ throw new Error(pass + "/" + count + " test cases passed");
++ }
++
++ Iterable<String> list(StandardLocation loc) throws IOException {
++ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
++ StandardJavaFileManager sfm = compiler.getStandardFileManager(null, null, null);
++ Set<JavaFileObject.Kind> kinds = Collections.singleton(JavaFileObject.Kind.CLASS);
++
++ List<String> list = new ArrayList<String>();
++ for (JavaFileObject fo: sfm.list(loc, testPackage, kinds, true)) {
++ //System.err.println(com.sun.tools.javac.util.Old199.getPath(fo));
++ list.add(sfm.inferBinaryName(loc, fo));
++ }
++ return list;
++ }
++
++ boolean test(String testClassName) throws Exception {
++ String[] args = new String[options.size() + 1];
++ options.toArray(args);
++ args[args.length - 1] = testClassName;
++ String oldOut = runOldJavap(args);
++ String newOut = runNewJavap(args);
++ boolean ok = oldOut.equals(newOut);
++ System.err.println((ok ? "pass" : "FAIL") + ": " + testClassName);
++ if (!ok && viewResults)
++ view(oldOut, newOut);
++ return ok;
++ }
++
++ String runOldJavap(String[] args) {
++ //System.err.println("OLD: " + Arrays.asList(args));
++ PrintStream oldOut = System.out;
++ ByteArrayOutputStream out = new ByteArrayOutputStream();
++ System.setOut(new PrintStream(out));
++ try {
++ sun.tools.javap.Main.entry(args);
++ } finally {
++ System.setOut(oldOut);
++ }
++ return out.toString();
++ }
++
++ String runNewJavap(String[] args) {
++ String[] nArgs = new String[args.length + 2];
++ nArgs[0] = "-XDcompat";
++ nArgs[1] = "-XDignore.symbol.file";
++ System.arraycopy(args, 0, nArgs, 2, args.length);
++ //System.err.println("NEW: " + Arrays.asList(nArgs));
++ StringWriter out = new StringWriter();
++ com.sun.tools.javap.Main.run(nArgs, new PrintWriter(out, true));
++ return out.toString();
++ }
++
++ File write(String text, String suffix) throws IOException {
++ File f = File.createTempFile("ListTest", suffix);
++ FileWriter out = new FileWriter(f);
++ out.write(text);
++ out.close();
++ return f;
++ }
++
++ void view(String oldOut, String newOut) throws Exception {
++ File oldFile = write(oldOut, "old");
++ File newFile = write(newOut, "new");
++ List<String> cmd = new ArrayList<String>();
++ cmd.addAll(viewCmd);
++ cmd.add(oldFile.getPath());
++ cmd.add(newFile.getPath());
++ Process p = new ProcessBuilder(cmd).redirectErrorStream(true).start();
++ p.getOutputStream().close();
++ String line;
++ BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
++ while ((line = in.readLine()) != null)
++ System.err.println(line);
++ in.close();
++ p.waitFor();
++ }
++
++ String testPackage = "java.lang";
++ List<String> options = Arrays.asList("-v");
++ boolean viewResults;
++ List<String> viewCmd;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/OptionTest.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/OptionTest.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,143 @@
++/*
++ * Copyright 2007 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.
++ */
++
++import java.io.*;
++import java.util.*;
++
++/*
++ * @test
++ * @bug 6439940
++ * @summary Cleanup javap implementation
++ * @run main/othervm OptionTest
++ */
++public class OptionTest {
++ public static void main(String[] args) throws Exception {
++ new OptionTest().run();
++ }
++
++ OptionTest() {
++ String v = System.getProperty("view.cmd");
++ if (v != null) {
++ viewResults = true;
++ viewCmd = Arrays.asList(v.split(" +"));
++ }
++ }
++
++
++ void run() throws Exception {
++ int count = 0;
++ int pass = 0;
++ // try combinations of options and compare old javap against new javap
++ for (int i = 0; i < (1<<8); i++) {
++ List<String> options = new ArrayList<String>();
++ if ((i & 0x01) != 0)
++ options.add("-c");
++ if ((i & 0x02) != 0)
++ options.add("-l");
++ if ((i & 0x04) != 0)
++ options.add("-public");
++ if ((i & 0x08) != 0)
++ options.add("-protected");
++ if ((i & 0x10) != 0)
++ options.add("-package");
++ if ((i & 0x20) != 0)
++ options.add("-private");
++ if ((i & 0x40) != 0)
++ options.add("-s");
++ if ((i & 0x80) != 0)
++ options.add("-verbose");
++ count++;
++ if (test(options))
++ pass++;
++ }
++
++ if (pass < count)
++ throw new Error(pass + "/" + count + " test cases passed");
++ }
++
++ boolean test(List<String> options) throws Exception {
++ String[] args = new String[options.size() + 1];
++ options.toArray(args);
++ args[args.length - 1] = testClassName;
++ String oldOut = runOldJavap(args);
++ String newOut = runNewJavap(args);
++ boolean ok = oldOut.equals(newOut);
++ System.err.println((ok ? "pass" : "FAIL") + ": " + options);
++ if (!ok && viewResults)
++ view(oldOut, newOut);
++ return ok;
++ }
++
++ String runOldJavap(String[] args) {
++ //System.err.println("OLD: " + Arrays.asList(args));
++ PrintStream oldOut = System.out;
++ ByteArrayOutputStream out = new ByteArrayOutputStream();
++ System.setOut(new PrintStream(out));
++ try {
++ sun.tools.javap.Main.entry(args);
++ } finally {
++ System.setOut(oldOut);
++ }
++ return out.toString();
++ }
++
++ String runNewJavap(String[] args) {
++ String[] nArgs = new String[args.length + 2];
++ nArgs[0] = "-XDcompat";
++ nArgs[1] = "-XDignore.symbol.file";
++ System.arraycopy(args, 0, nArgs, 2, args.length);
++ //System.err.println("NEW: " + Arrays.asList(nArgs));
++ StringWriter out = new StringWriter();
++ com.sun.tools.javap.Main.run(nArgs, new PrintWriter(out, true));
++ return out.toString();
++ }
++
++ File write(String text, String suffix) throws IOException {
++ File f = File.createTempFile("OptionTest", suffix);
++ FileWriter out = new FileWriter(f);
++ out.write(text);
++ out.close();
++ return f;
++ }
++
++ void view(String oldOut, String newOut) throws Exception {
++ File oldFile = write(oldOut, "old");
++ File newFile = write(newOut, "new");
++ List<String> cmd = new ArrayList<String>();
++ cmd.addAll(viewCmd);
++ cmd.add(oldFile.getPath());
++ cmd.add(newFile.getPath());
++ Process p = new ProcessBuilder(cmd).redirectErrorStream(true).start();
++ p.getOutputStream().close();
++ String line;
++ BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
++ while ((line = in.readLine()) != null)
++ System.err.println(line);
++ in.close();
++ p.waitFor();
++ }
++
++ String testClassName = "java.lang.SecurityManager";
++ boolean viewResults;
++ List<String> viewCmd;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T4075403.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T4075403.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,73 @@
++/*
++ * 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 4075403
++ * @summary Use javap to inquire about a specific inner class
++ */
++
++
++import java.io.*;
++
++public class T4075403 {
++ public static void main(String[] args) throws Exception {
++ new T4075403().run();
++ }
++
++ public void run() throws IOException {
++
++ File javaFile = writeTestFile();
++ File classFile = compileTestFile(javaFile);
++ javap("Outer.Inner");
++ }
++
++ File writeTestFile() throws IOException {
++ File f = new File("Outer.java");
++ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
++ out.println("class Outer { ");
++ out.println(" class Inner { }");
++ out.println("}");
++ out.close();
++ return f;
++ }
++
++ File compileTestFile(File f) {
++ int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
++ if (rc != 0)
++ throw new Error("compilation failed. rc=" + rc);
++ String path = f.getPath();
++ return new File(path.substring(0, path.length() - 5) + ".class");
++ }
++
++ String javap(String className) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(new String[] { "-classpath", ".", className }, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ System.out.println(sw.toString());
++ return sw.toString();
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T4459541.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T4459541.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,112 @@
++/*
++ * 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 4459541
++ * @summary "javap -l" shows line numbers as signed short; they should be unsigned.
++ */
++
++import java.io.*;
++
++public class T4459541 {
++ public static void main(String[] args) throws Exception {
++ new T4459541().run();
++ }
++
++ public void run() throws IOException {
++ File javaFile = writeTestFile();
++ File classFile = compileTestFile(javaFile);
++ String output = javap(classFile);
++ verify(output);
++ }
++
++ File writeTestFile() throws IOException {
++ File f = new File("Test.java");
++ out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
++ println("class Test {");
++ println("void begin(int i) {");
++ println("i++;");
++ println("i++;");
++ println("}");
++ while (line < 32750)
++ println("// " + line);
++ println("void before_32767(int i) {");
++ println("i++;");
++ println("i++;");
++ println("}");
++ while (line < 32768-4)
++ println("// " + line);
++ println("void straddle_32768(int i) {");
++ while (line < 32768+4)
++ println("i++;");
++ println("}");
++ while (line < 65520)
++ println("// " + line);
++ println("void between_32768_and_65536(int i) {");
++ println("i++;");
++ println("i++;");
++ println("}");
++ while (line < 65536-4)
++ println("// " + line);
++ println("void straddle_65536(int i) {");
++ while (line < 65536+4)
++ println("i++;");
++ println("}");
++ println("}");
++ out.close();
++ return f;
++ }
++
++ File compileTestFile(File f) {
++ int rc = com.sun.tools.javac.Main.compile(new String[] { f.getPath() });
++ if (rc != 0)
++ throw new Error("compilation failed. rc=" + rc);
++ String path = f.getPath();
++ return new File(path.substring(0, path.length() - 5) + ".class");
++ }
++
++ String javap(File f) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(new String[] { "-l", f.getPath() }, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ return sw.toString();
++ }
++
++ void verify(String output) {
++ System.out.println(output);
++ if (output.indexOf("-") >= 0)
++ throw new Error("- found in output");
++ }
++
++ void println(String text) {
++ out.println(text);
++ line++;
++ }
++
++ PrintWriter out;
++ int line = 1;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T4501660.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T4501660.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,76 @@
++/*
++ * 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 4501660
++ * @summary change diagnostic of -help as 'print this help message and exit'
++ * (actually, verify -help does not cause premature exit)
++ */
++
++import java.io.*;
++import java.util.zip.*;
++
++public class T4501660 {
++ public static void main(String[] args) throws Exception {
++ new T4501660().run();
++ }
++
++ public void run() throws IOException {
++ String testClasses = System.getProperty("test.classes", ".");
++ String output = javap("-classpath", testClasses, "-help", "T4501660");
++ verify(output,
++ "-public", "-protected", "-private", // check -help output is present
++ "class T4501660" // check class output is present
++ );
++
++ if (errors > 0)
++ throw new Error(errors + " found.");
++ }
++
++ String javap(String... args) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ //sun.tools.javap.Main.entry(args);
++ int rc = com.sun.tools.javap.Main.run(args, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ System.out.println(sw);
++ return sw.toString();
++ }
++
++ void verify(String output, String... expects) {
++ for (String expect: expects) {
++ if (output.indexOf(expect)< 0)
++ error(expect + " not found");
++ }
++ }
++
++ void error(String msg) {
++ System.err.println(msg);
++ errors++;
++ }
++
++ int errors;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T4876942.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T4876942.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,70 @@
++/*
++ * 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 4876942
++ * @summary javap invoked without args does not print help screen
++ */
++
++import java.io.*;
++import java.util.zip.*;
++
++public class T4876942 {
++ public static void main(String[] args) throws Exception {
++ new T4876942().run();
++ }
++
++ public void run() throws IOException {
++ String output = javap();
++ verify(output, "-public", "-protected", "-private"); // check that some of the options are listed
++
++ if (errors > 0)
++ throw new Error(errors + " found.");
++ }
++
++ String javap(String... args) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ //sun.tools.javap.Main.entry(args);
++ int rc = com.sun.tools.javap.Main.run(args, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ return sw.toString();
++ }
++
++ void verify(String output, String... expects) {
++ for (String expect: expects) {
++ if (output.indexOf(expect)< 0)
++ error(expect + " not found");
++ }
++ }
++
++ void error(String msg) {
++ System.err.println(msg);
++ errors++;
++ }
++
++ int errors;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T4880663.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T4880663.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,88 @@
++/*
++ * 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 4880663
++ * @summary javap could output whitespace between class name and opening brace
++ */
++
++
++import java.io.*;
++
++public class T4880663 {
++ public static void main(String[] args) throws Exception {
++ new T4880663().run();
++ }
++
++ public void run() throws IOException {
++ File javaFile = writeTestFile();
++ File classFile = compileTestFile(javaFile);
++ verify(classFile, "class Test {");
++
++ if (errors > 0)
++ throw new Error(errors + " found.");
++ }
++
++ File writeTestFile() throws IOException {
++ File f = new File("Test.java");
++ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
++ out.println("class Test { }");
++ out.close();
++ return f;
++ }
++
++ File compileTestFile(File f) {
++ int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
++ if (rc != 0)
++ throw new Error("compilation failed. rc=" + rc);
++ String path = f.getPath();
++ return new File(path.substring(0, path.length() - 5) + ".class");
++ }
++
++ String javap(File classFile) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(new String[] { classFile.getPath() }, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ System.out.println(sw.toString());
++ return sw.toString();
++ }
++
++ void verify(File classFile, String... expects) {
++ String output = javap(classFile);
++ for (String expect: expects) {
++ if (output.indexOf(expect)< 0)
++ error(expect + " not found");
++ }
++ }
++
++ void error(String msg) {
++ System.err.println(msg);
++ errors++;
++ }
++
++ int errors;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T4975569.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T4975569.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,94 @@
++/*
++ * 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 4975569 6622215
++ * @summary javap doesn't print new flag bits
++ */
++
++import java.io.*;
++import java.util.*;
++
++public class T4975569
++{
++ public static void main(String... args) {
++ new T4975569().run();
++ }
++
++ void run() {
++ verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION");
++ verify("T4975569$E", "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM");
++ verify("T4975569$S", "flags: ACC_BRIDGE, ACC_SYNTHETIC",
++ "InnerClasses: \n static");
++ verify("T4975569$V", "void m(java.lang.String...)",
++ "flags: ACC_VARARGS");
++ verify("T4975569$Prot", "InnerClasses: \n protected");
++ //verify("T4975569$Priv", "InnerClasses");
++ if (errors > 0)
++ throw new Error(errors + " found.");
++ }
++
++ void verify(String className, String... expects) {
++ String output = javap(className);
++ for (String expect: expects) {
++ if (output.indexOf(expect)< 0)
++ error(expect + " not found");
++ }
++ }
++
++ void error(String msg) {
++ System.err.println(msg);
++ errors++;
++ }
++
++ int errors;
++
++ String javap(String className) {
++ String testClasses = System.getProperty("test.classes", ".");
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ String[] args = { "-v", "-classpath", testClasses, className };
++ int rc = com.sun.tools.javap.Main.run(args, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ String output = sw.toString();
++ System.out.println("class " + className);
++ System.out.println(output);
++ return output;
++ }
++
++ List x() { return null; };
++
++ class V { void m(String... args) { } }
++ enum E { e; }
++ @interface Anno { }
++ static class S extends T4975569 {
++ ArrayList x() { return null; }
++ }
++
++ protected class Prot { }
++ //private class Priv { int i; }
++}
++
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T6271787.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T6271787.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,90 @@
++/*
++ * 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 6271787
++ * @summary javap dumps LocalVariableTypeTable attribute in hex, needs to print a table
++ */
++
++import java.io.*;
++
++public class T6271787 {
++ public static void main(String[] args) throws Exception {
++ new T6271787().run();
++ }
++
++ public void run() throws IOException {
++ File javaFile = writeTestFile();
++ File classFile = compileTestFile(javaFile);
++
++ verify(classFile,
++ "LocalVariableTypeTable:",
++ "0 5 0 this LTest<TT;>;" // should consider decoding this in javap
++ );
++
++ if (errors > 0)
++ throw new Error(errors + " found.");
++ }
++
++ File writeTestFile() throws IOException {
++ File f = new File("Test.java");
++ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
++ out.println("class Test<T> { }");
++ out.close();
++ return f;
++ }
++
++ File compileTestFile(File f) {
++ int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
++ if (rc != 0)
++ throw new Error("compilation failed. rc=" + rc);
++ String path = f.getPath();
++ return new File(path.substring(0, path.length() - 5) + ".class");
++ }
++
++ String javap(File f) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ return sw.toString();
++ }
++
++ void verify(File classFile, String... expects) {
++ String output = javap(classFile);
++ for (String expect: expects) {
++ if (output.indexOf(expect)< 0)
++ error(expect + " not found");
++ }
++ }
++
++ void error(String msg) {
++ System.err.println(msg);
++ errors++;
++ }
++
++ int errors;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T6474890.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T6474890.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,95 @@
++/*
++ * 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 6474890
++ * @summary javap does not open .zip files in -classpath
++ */
++
++import java.io.*;
++import java.util.zip.*;
++
++public class T6474890 {
++ public static void main(String[] args) throws Exception {
++ new T6474890().run();
++ }
++
++ public void run() throws IOException {
++ File classDir = new File("classes");
++ classDir.mkdir();
++
++ String className = "Test";
++ File javaFile = writeTestFile(className);
++ compileTestFile(classDir, javaFile);
++
++ File zipFile = zip(classDir, new File(classDir + ".zip"));
++ javap("-classpath", zipFile.getPath(), className);
++
++ File jarFile = zip(classDir, new File(classDir + ".jar"));
++ javap("-classpath", zipFile.getPath(), className);
++ }
++
++ File writeTestFile(String name) throws IOException {
++ File f = new File(name + ".java");
++ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
++ out.println("class " + name + " { }");
++ out.close();
++ return f;
++ }
++
++ void compileTestFile(File classDir, File file) {
++ int rc = com.sun.tools.javac.Main.compile(
++ new String[] { "-d", classDir.getPath(), file.getPath() });
++ if (rc != 0)
++ throw new Error("compilation failed. rc=" + rc);
++ }
++
++ File zip(File dir, File zipFile) throws IOException {
++ ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile));
++ for (File file: dir.listFiles()) {
++ if (file.isFile()) {
++ byte[] data = new byte[(int) file.length()];
++ DataInputStream in = new DataInputStream(new FileInputStream(file));
++ in.readFully(data);
++ in.close();
++ zipOut.putNextEntry(new ZipEntry(file.getName()));
++ zipOut.write(data, 0, data.length);
++ zipOut.closeEntry();
++ }
++ }
++ zipOut.close();
++ return zipFile;
++ }
++
++ String javap(String... args) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ //sun.tools.javap.Main.entry(args);
++ int rc = com.sun.tools.javap.Main.run(args, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ return sw.toString();
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T6587786.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T6587786.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,52 @@
++/*
++ * 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 6587786
++ * @summary Javap throws error : "ERROR:Could not find <classname>" for JRE classes
++ */
++
++import java.io.*;
++
++public class T6587786 {
++ public static void main(String[] args) throws Exception {
++ new T6587786().run();
++ }
++
++ public void run() throws IOException {
++ javap("com.sun.javadoc.Doc", "com.sun.crypto.provider.ai");
++ javap("com.sun.crypto.provider.ai", "com.sun.javadoc.ClassDoc");
++ }
++
++ void javap(String... args) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ //sun.tools.javap.Main.entry(args);
++ int rc = com.sun.tools.javap.Main.run(args, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ System.out.println(sw.toString());
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T6622216.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T6622216.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,77 @@
++/*
++ * 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 6622216
++ * @summary javap names some attributes incorrectly
++ */
++
++import java.io.*;
++
++public class T6622216 {
++ public static void main(String[] args) throws Exception {
++ new T6622216().run();
++ }
++
++ public void run() throws IOException {
++ File javaFile = writeTestFile();
++ File classFile = compileTestFile(javaFile);
++ String output = javap(classFile);
++ verify(output);
++ }
++
++ File writeTestFile() throws IOException {
++ File f = new File("Outer.java");
++ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
++ out.println("class Outer {");
++ out.println(" class Inner { }");
++ out.println("}");
++ out.close();
++ return f;
++ }
++
++ File compileTestFile(File f) {
++ int rc = com.sun.tools.javac.Main.compile(new String[] { f.getPath() });
++ if (rc != 0)
++ throw new Error("compilation failed. rc=" + rc);
++ String path = f.getPath();
++ return new File(path.substring(0, path.length() - 5) + ".class");
++ }
++
++ String javap(File f) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ return sw.toString();
++ }
++
++ void verify(String output) {
++ System.out.println(output);
++ if (output.indexOf("InnerClasses") == -1)
++ throw new Error("InnerClasses not found in output");
++ }
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T6622232.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T6622232.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,97 @@
++/*
++ * 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 6622232
++ * @summary javap gets whitespace confused
++ */
++
++import java.io.*;
++
++public class T6622232 {
++ public static void main(String[] args) throws Exception {
++ new T6622232().run();
++ }
++
++ public void run() throws IOException {
++ File javaFile = writeTestFile();
++ File classFile = compileTestFile(javaFile);
++ String output = javap(classFile);
++
++ // these are all examples of bad whitespace from old javap
++ verifyNot(output,
++ "\\Q Constant value: int 3Deprecated: true\\E",
++ "^Deprecated: true",
++ "\\Q throws java.lang.Exception, java.lang.Error Deprecated: true\\E"
++ );
++
++ if (errors > 0)
++ throw new Error(errors + " found.");
++ }
++
++ File writeTestFile() throws IOException {
++ File f = new File("Test.java");
++ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
++ out.println("class Test { ");
++ out.println(" @Deprecated static final int f1 = 3;");
++ out.println(" @Deprecated int f2;");
++ out.println(" @Deprecated void m() throws Exception, Error { }");
++ out.println("}");
++ out.close();
++ return f;
++ }
++
++ File compileTestFile(File f) {
++ int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
++ if (rc != 0)
++ throw new Error("compilation failed. rc=" + rc);
++ String path = f.getPath();
++ return new File(path.substring(0, path.length() - 5) + ".class");
++ }
++
++ String javap(File f) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ System.out.println(sw.toString());
++ return sw.toString();
++ }
++
++ void verifyNot(String output, String... unexpects) {
++ for (String unexpect: unexpects) {
++ if (output.matches(unexpect))
++ error(unexpect + " unexpectedly found");
++ }
++ }
++
++ void error(String msg) {
++ System.err.println(msg);
++ errors++;
++ }
++
++ int errors;
++}
+diff -r 8e38c8fe0a0b -r bfd7bb421825 test/tools/javap/T6622260.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T6622260.java Tue Oct 22 01:03:49 2013 +0100
+@@ -0,0 +1,197 @@
++/*
++ * 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 6622260
++ * @summary javap prints negative bytes incorrectly in hex
++ */
++
++import java.io.*;
++
++public class T6622260 {
++ public static void main(String[] args) throws Exception {
++ new T6622260().run();
++ }
++
++ public void run() throws IOException {
++ File javaFile = writeTestFile();
++ File classFile = compileTestFile(javaFile);
++ modifyClassFile(classFile);
++ String output = javap(classFile);
++ verify(output);
++ }
++
++ File writeTestFile() throws IOException {
++ File f = new File("Test.java");
++ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
++ out.println("@Deprecated class Test { int f; void m() { } }");
++ out.close();
++ return f;
++ }
++
++ File compileTestFile(File f) {
++ int rc = com.sun.tools.javac.Main.compile(new String[] { f.getPath() });
++ if (rc != 0)
++ throw new Error("compilation failed. rc=" + rc);
++ String path = f.getPath();
++ return new File(path.substring(0, path.length() - 5) + ".class");
++ }
++
++ void modifyClassFile(File f) throws IOException {
++ String newAttributeName = "NonstandardAttribute";
++ byte[] newAttributeData = { 0, 1, 2, 127, (byte)128, (byte)129, (byte)254, (byte)255 };
++
++ DataInputStream in = new DataInputStream(new FileInputStream(f));
++ byte[] data = new byte[(int) f.length()];
++ in.readFully(data);
++ in.close();
++
++ in = new DataInputStream(new ByteArrayInputStream(data));
++ in.skipBytes(4); // magic
++ in.skipBytes(2); // minor
++ in.skipBytes(2); // minor
++
++ int constantPoolPos = data.length - in.available();
++ int constant_pool_count = skipConstantPool(in);
++
++ int flagsPos = data.length - in.available();
++ in.skipBytes(2); // access_flags
++ in.skipBytes(2); // this_class
++ in.skipBytes(2); // super_class
++
++ int interfaces_count = in.readUnsignedShort();
++ in.skipBytes(interfaces_count * 2);
++
++ int field_count = in.readUnsignedShort();
++ for (int i = 0; i < field_count; i++) {
++ in.skipBytes(6); // access_flags, name_index, descriptor_index
++ skipAttributes(in);
++ }
++
++ int method_count = in.readUnsignedShort();
++ for (int i = 0; i < method_count; i++) {
++ in.skipBytes(6); // access_flags, name_index, descriptor_index
++ skipAttributes(in);
++ }
++
++ int classAttributesPos = data.length - in.available();
++ int attributes_count = in.readUnsignedShort();
++
++ f.renameTo(new File(f.getPath() + ".BAK"));
++ DataOutputStream out = new DataOutputStream(new FileOutputStream(f));
++
++ // copy head
++ out.write(data, 0, constantPoolPos);
++
++ // copy constant pool, adding in name of new attribute
++ out.writeShort(constant_pool_count + 1);
++ out.write(data, constantPoolPos + 2, flagsPos - constantPoolPos - 2);
++ out.write(1); // CONSTANT_Utf8
++ out.writeUTF(newAttributeName);
++
++ // copy flags, class, superclass, interfaces, fields and methods
++ out.write(data, flagsPos, classAttributesPos - flagsPos);
++
++ // copy class attributes, adding in new attribute
++ out.writeShort(attributes_count + 1);
++ out.write(data, classAttributesPos + 2, data.length - classAttributesPos - 2);
++ out.writeShort(constant_pool_count); // index of new attribute name
++ out.writeInt(newAttributeData.length);
++ out.write(newAttributeData);
++ out.close();
++ }
++
++ int skipConstantPool(DataInputStream in) throws IOException {
++ int constant_pool_count = in.readUnsignedShort();
++ for (int i = 1; i < constant_pool_count; i++) {
++ int tag = in.readUnsignedByte();
++ switch (tag) {
++ case 1: // CONSTANT_Utf8
++ int length = in.readUnsignedShort();
++ in.skipBytes(length); // bytes
++ break;
++
++ case 3: // CONSTANT_Integer
++ case 4: // CONSTANT_Float
++ in.skipBytes(4); // bytes
++ break;
++
++ case 5: // CONSTANT_Long
++ case 6: // CONSTANT_Double
++ in.skipBytes(8); // high_bytes, low_bytes
++ break;
++
++ case 7: // CONSTANT_Class
++ in.skipBytes(2); // name_index
++ break;
++
++ case 8: // CONSTANT_String
++ in.skipBytes(2); // string_index
++ break;
++
++ case 9: // CONSTANT_FieldRef
++ case 10: // CONSTANT_Methodref
++ case 11: // CONSTANT_InterfaceMethodref
++ in.skipBytes(4); // class_index, name_and_type_index
++ break;
++
++ case 12: // CONSTANT_NameAndType
++ in.skipBytes(4); // name_index, descriptor_index
++ break;
++
++ default:
++ throw new Error("constant pool tag: " + tag);
++ }
++ }
++ return constant_pool_count;
++ }
++
++ int skipAttributes(DataInputStream in) throws IOException {
++ int attributes_count = in.readUnsignedShort();
++ for (int i = 0; i < attributes_count; i++) {
++ in.skipBytes(2); // attribute_name_index;
++ int length = in.readInt();
++ in.skipBytes(length); // info
++ }
++ return attributes_count;
++ }
++
++ String javap(File f) {
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ return sw.toString();
++ }
++
++ void verify(String output) {
++ System.out.println(output);
++ if (output.indexOf("-") >= 0)
++ throw new Error("- found in output");
++ if (output.indexOf("FFFFFF") >= 0)
++ throw new Error("FFFFFF found in output");
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/4111861-static_fields.patch b/java/openjdk6/files/icedtea/openjdk/4111861-static_fields.patch
new file mode 100644
index 000000000000..9612d7b0b577
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/4111861-static_fields.patch
@@ -0,0 +1,280 @@
+# HG changeset patch
+# User jjg
+# Date 1217887742 25200
+# Mon Aug 04 15:09:02 2008 -0700
+# Node ID 6134c146043a3e9dd12ee73ca32ce56ac1c95e3a
+# Parent 17dfaebe23044c48bcd5ed0730ce2358543ac459
+4111861: static final field contents are not displayed
+Reviewed-by: ksrini
+
+diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/ClassWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue May 19 11:43:50 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon Aug 04 15:09:02 2008 -0700
+@@ -35,6 +35,7 @@
+ import com.sun.tools.classfile.Code_attribute;
+ import com.sun.tools.classfile.ConstantPool;
+ import com.sun.tools.classfile.ConstantPoolException;
++import com.sun.tools.classfile.ConstantValue_attribute;
+ import com.sun.tools.classfile.Descriptor;
+ import com.sun.tools.classfile.DescriptorException;
+ import com.sun.tools.classfile.Exceptions_attribute;
+@@ -189,6 +190,14 @@
+ }
+ print(" ");
+ print(getFieldName(f));
++ if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents
++ Attribute a = f.attributes.get(Attribute.ConstantValue);
++ if (a instanceof ConstantValue_attribute) {
++ print(" = ");
++ ConstantValue_attribute cv = (ConstantValue_attribute) a;
++ print(getConstantValue(f.descriptor, cv.constantvalue_index));
++ }
++ }
+ print(";");
+ println();
+
+@@ -485,6 +494,81 @@
+ }
+ }
+
++ /**
++ * Get the value of an entry in the constant pool as a Java constant.
++ * Characters and booleans are represented by CONSTANT_Intgere entries.
++ * Character and string values are processed to escape characters outside
++ * the basic printable ASCII set.
++ * @param d the descriptor, giving the expected type of the constant
++ * @param index the index of the value in the constant pool
++ * @return a printable string containing the value of the constant.
++ */
++ String getConstantValue(Descriptor d, int index) {
++ try {
++ ConstantPool.CPInfo cpInfo = constant_pool.get(index);
++
++ switch (cpInfo.getTag()) {
++ case ConstantPool.CONSTANT_Integer: {
++ ConstantPool.CONSTANT_Integer_info info =
++ (ConstantPool.CONSTANT_Integer_info) cpInfo;
++ String t = d.getValue(constant_pool);
++ if (t.equals("C")) { // character
++ return getConstantCharValue((char) info.value);
++ } else if (t.equals("Z")) { // boolean
++ return String.valueOf(info.value == 1);
++ } else { // other: assume integer
++ return String.valueOf(info.value);
++ }
++ }
++
++ case ConstantPool.CONSTANT_String: {
++ ConstantPool.CONSTANT_String_info info =
++ (ConstantPool.CONSTANT_String_info) cpInfo;
++ return getConstantStringValue(info.getString());
++ }
++
++ default:
++ return constantWriter.stringValue(cpInfo);
++ }
++ } catch (ConstantPoolException e) {
++ return "#" + index;
++ }
++ }
++
++ private String getConstantCharValue(char c) {
++ StringBuilder sb = new StringBuilder();
++ sb.append('\'');
++ sb.append(esc(c, '\''));
++ sb.append('\'');
++ return sb.toString();
++ }
++
++ private String getConstantStringValue(String s) {
++ StringBuilder sb = new StringBuilder();
++ sb.append("\"");
++ for (int i = 0; i < s.length(); i++) {
++ sb.append(esc(s.charAt(i), '"'));
++ }
++ sb.append("\"");
++ return sb.toString();
++ }
++
++ private String esc(char c, char quote) {
++ if (32 <= c && c <= 126 && c != quote)
++ return String.valueOf(c);
++ else switch (c) {
++ case '\b': return "\\b";
++ case '\n': return "\\n";
++ case '\t': return "\\t";
++ case '\f': return "\\f";
++ case '\r': return "\\r";
++ case '\\': return "\\\\";
++ case '\'': return "\\'";
++ case '\"': return "\\\"";
++ default: return String.format("\\u%04x", (int) c);
++ }
++ }
++
+ private Options options;
+ private AttributeWriter attrWriter;
+ private CodeWriter codeWriter;
+diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/JavapTask.java
+--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue May 19 11:43:50 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Aug 04 15:09:02 2008 -0700
+@@ -222,6 +222,12 @@
+ void process(JavapTask task, String opt, String arg) {
+ task.options.ignoreSymbolFile = true;
+ }
++ },
++
++ new Option(false, "-constants") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.showConstants = true;
++ }
+ }
+
+ };
+diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/Options.java
+--- langtools/src/share/classes/com/sun/tools/javap/Options.java Tue May 19 11:43:50 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/Options.java Mon Aug 04 15:09:02 2008 -0700
+@@ -77,6 +77,7 @@
+ public boolean showDisassembled;
+ public boolean showInternalSignatures;
+ public boolean showAllAttrs;
++ public boolean showConstants;
+
+ public boolean compat; // bug-for-bug compatibility mode with old javap
+ public boolean jsr277;
+diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/resources/javap.properties
+--- langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue May 19 11:43:50 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Mon Aug 04 15:09:02 2008 -0700
+@@ -58,5 +58,9 @@
+ main.opt.bootclasspath=\
+ \ -bootclasspath <path> Override location of bootstrap class files
+
++main.opt.constants=\
++\ -constants Show static final constants
+
+
++
++
+diff -r 17dfaebe2304 -r 6134c146043a test/tools/javap/4111861/A.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/4111861/A.java Mon Aug 04 15:09:02 2008 -0700
+@@ -0,0 +1,14 @@
++class A {
++ public static final int i = 42;
++ public static final boolean b = true;
++ public static final float f = 1.0f;
++ public static final double d = 1.0d;
++ public static final short s = 1;
++ public static final long l = 1l;
++ public static final char cA = 'A';
++ public static final char c0 = '\u0000';
++ public static final char cn = '\n';
++ public static final char cq1 = '\'';
++ public static final char cq2 = '"';
++ public static final java.lang.String t1 = "abc \u0000 \f\n\r\t'\"";
++}
+diff -r 17dfaebe2304 -r 6134c146043a test/tools/javap/4111861/T4111861.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/4111861/T4111861.java Mon Aug 04 15:09:02 2008 -0700
+@@ -0,0 +1,101 @@
++/*
++ * 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.
++ */
++
++import java.io.*;
++
++/*
++ * @test
++ * @bug 4111861
++ * @summary static final field contents are not displayed
++ */
++public class T4111861 {
++ public static void main(String... args) throws Exception {
++ new T4111861().run();
++ }
++
++ void run() throws Exception {
++ File testSrc = new File(System.getProperty("test.src", "."));
++ File a_java = new File(testSrc, "A.java");
++ javac("-d", ".", a_java.getPath());
++
++ String out = javap("-classpath", ".", "-constants", "A");
++
++ String a = read(a_java);
++
++ if (!filter(out).equals(filter(read(a_java)))) {
++ System.out.println(out);
++ throw new Exception("unexpected output");
++ }
++ }
++
++ String javac(String... args) throws Exception {
++ StringWriter sw = new StringWriter();
++ PrintWriter pw = new PrintWriter(sw);
++ int rc = com.sun.tools.javac.Main.compile(args, pw);
++ if (rc != 0)
++ throw new Exception("javac failed, rc=" + rc);
++ return sw.toString();
++ }
++
++ String javap(String... args) throws Exception {
++ StringWriter sw = new StringWriter();
++ PrintWriter pw = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(args, pw);
++ if (rc != 0)
++ throw new Exception("javap failed, rc=" + rc);
++ return sw.toString();
++ }
++
++ String read(File f) throws IOException {
++ StringBuilder sb = new StringBuilder();
++ BufferedReader in = new BufferedReader(new FileReader(f));
++ try {
++ String line;
++ while ((line = in.readLine()) != null) {
++ sb.append(line);
++ sb.append('\n');
++ }
++ } finally {
++ in.close();
++ }
++ return sb.toString();
++ }
++
++ // return those lines beginning "public static final"
++ String filter(String s) throws IOException {
++ StringBuilder sb = new StringBuilder();
++ BufferedReader in = new BufferedReader(new StringReader(s));
++ try {
++ String line;
++ while ((line = in.readLine()) != null) {
++ if (line.indexOf("public static final") > 0) {
++ sb.append(line);
++ sb.append('\n');
++ }
++ }
++ } finally {
++ in.close();
++ }
++ return sb.toString();
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/4501661-disallow_mixing.patch b/java/openjdk6/files/icedtea/openjdk/4501661-disallow_mixing.patch
new file mode 100644
index 000000000000..41bcd24728dd
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/4501661-disallow_mixing.patch
@@ -0,0 +1,222 @@
+# HG changeset patch
+# User jjg
+# Date 1215565579 25200
+# Tue Jul 08 18:06:19 2008 -0700
+# Node ID 8f5d8429b3f18ee4c9820ac1fb597f63c55911f3
+# Parent 4f38abed863c89ee101a3af495e7293df04a4a0e
+4501661: disallow mixing -public, -private, and -protected options at the same time
+Reviewed-by: ksrini
+
+diff -r 4f38abed863c -r 8f5d8429b3f1 src/share/classes/com/sun/tools/javap/JavapTask.java
+--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Sat Aug 08 17:56:37 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Jul 08 18:06:19 2008 -0700
+@@ -145,24 +145,31 @@
+
+ new Option(false, "-public") {
+ void process(JavapTask task, String opt, String arg) {
++ task.options.accessOptions.add(opt);
+ task.options.showAccess = AccessFlags.ACC_PUBLIC;
+ }
+ },
+
+ new Option(false, "-protected") {
+ void process(JavapTask task, String opt, String arg) {
++ task.options.accessOptions.add(opt);
+ task.options.showAccess = AccessFlags.ACC_PROTECTED;
+ }
+ },
+
+ new Option(false, "-package") {
+ void process(JavapTask task, String opt, String arg) {
++ task.options.accessOptions.add(opt);
+ task.options.showAccess = 0;
+ }
+ },
+
+ new Option(false, "-p", "-private") {
+ void process(JavapTask task, String opt, String arg) {
++ if (!task.options.accessOptions.contains("-p") &&
++ !task.options.accessOptions.contains("-private")) {
++ task.options.accessOptions.add(opt);
++ }
+ task.options.showAccess = AccessFlags.ACC_PRIVATE;
+ }
+ },
+@@ -422,6 +429,16 @@
+ throw new BadArgs("err.unknown.option", arg).showUsage(true);
+ }
+
++ if (!options.compat && options.accessOptions.size() > 1) {
++ StringBuilder sb = new StringBuilder();
++ for (String opt: options.accessOptions) {
++ if (sb.length() > 0)
++ sb.append(" ");
++ sb.append(opt);
++ }
++ throw new BadArgs("err.incompatible.options", sb);
++ }
++
+ if (options.ignoreSymbolFile && fileManager instanceof JavapFileManager)
+ ((JavapFileManager) fileManager).setIgnoreSymbolFile(true);
+
+diff -r 4f38abed863c -r 8f5d8429b3f1 src/share/classes/com/sun/tools/javap/Options.java
+--- langtools/src/share/classes/com/sun/tools/javap/Options.java Sat Aug 08 17:56:37 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/Options.java Tue Jul 08 18:06:19 2008 -0700
+@@ -25,6 +25,8 @@
+
+ package com.sun.tools.javap;
+
++import java.util.HashSet;
++import java.util.Set;
+ import com.sun.tools.classfile.AccessFlags;
+
+ /*
+@@ -74,6 +76,7 @@
+ public boolean showFlags;
+ public boolean showLineAndLocalVariableTables;
+ public int showAccess;
++ public Set<String> accessOptions = new HashSet<String>();
+ public boolean showDisassembled;
+ public boolean showInternalSignatures;
+ public boolean showAllAttrs;
+diff -r 4f38abed863c -r 8f5d8429b3f1 src/share/classes/com/sun/tools/javap/resources/javap.properties
+--- langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Sat Aug 08 17:56:37 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue Jul 08 18:06:19 2008 -0700
+@@ -7,6 +7,7 @@
+ err.end.of.file=unexpected end of file while reading {0}
+ err.file.not.found=file not found: {0}
+ err.h.not.supported=-h is no longer available - use the 'javah' program
++err.incompatible.options=bad combination of options: {0}
+ err.internal.error=internal error: {0} {1} {2}
+ err.ioerror=IO error reading {0}: {1}
+ err.missing.arg=no value given for {0}
+diff -r 4f38abed863c -r 8f5d8429b3f1 test/tools/javap/T4501661.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T4501661.java Tue Jul 08 18:06:19 2008 -0700
+@@ -0,0 +1,126 @@
++/*
++ * 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.
++ */
++
++import java.io.*;
++import java.util.*;
++
++/*
++ * @test
++ * @bug 4501661
++ * @summary disallow mixing -public, -private, and -protected
++ */
++public class T4501661 {
++ public static void main(String... args) throws Exception {
++ new T4501661().run();
++ }
++
++ void run() throws Exception {
++ File javaFile = writeTestFile();
++ File classFile = compileTestFile(javaFile);
++ boolean[] values = { false, true };
++ for (boolean priv: values) {
++ for (boolean prot: values) {
++ for (boolean publ: values) {
++ test(priv, prot, publ, classFile);
++ }
++ }
++ }
++
++ if (errors > 0)
++ throw new Exception(errors + " errors found");
++ }
++
++ void test(boolean priv, boolean prot, boolean publ, File classFile) {
++ List<String> args = new ArrayList<String>();
++ if (priv)
++ args.add("-private");
++ if (prot)
++ args.add("-protected");
++ if (publ)
++ args.add("-public");
++ boolean expectOK = (args.size() <= 1);
++ args.add(classFile.getPath());
++ String out = javap(args, expectOK);
++ if (out == null)
++ return;
++ if (!priv && !prot && !publ)
++ checkNone(out, "private");
++ if (prot)
++ checkNone(out, "private", "package");
++ if (publ)
++ checkNone(out, "private", "package", "protected");
++ }
++
++ File writeTestFile() throws IOException {
++ File f = new File("Test.java");
++ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
++ out.println("abstract class Test { ");
++ out.println(" public void public_m() { }");
++ out.println(" protected void protected_m() { }");
++ out.println(" private void private_m() { }");
++ out.println(" void package_m() { }");
++ out.println("}");
++ out.close();
++ return f;
++ }
++
++ File compileTestFile(File f) {
++ int rc = com.sun.tools.javac.Main.compile(new String[] { "-g", f.getPath() });
++ if (rc != 0)
++ throw new Error("compilation failed. rc=" + rc);
++ String path = f.getPath();
++ return new File(path.substring(0, path.length() - 5) + ".class");
++ }
++
++ String javap(List<String> args, boolean expectOK) {
++ StringWriter sw = new StringWriter();
++ PrintWriter pw = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw);
++ System.err.println(args);
++ System.err.println(sw);
++ if (expectOK) {
++ if (rc == 0)
++ return sw.toString();
++ else
++ error("javap failed unexpectedly; rc=" + rc + "\n" + sw);
++ } else {
++ if (rc == 0)
++ error("javap succeeded unexpectedly");
++ }
++ return null;
++ }
++
++ void checkNone(String log, String... words) {
++ for (String word: words) {
++ if (log.indexOf(word) != -1)
++ error("\"" + word + "\" unexpectedly found in output");
++ }
++ }
++
++ void error(String msg) {
++ System.err.println("error: " + msg);
++ errors++;
++ }
++
++ int errors;
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/4884240-javap_additional_option.patch b/java/openjdk6/files/icedtea/openjdk/4884240-javap_additional_option.patch
new file mode 100644
index 000000000000..aada7a068f00
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/4884240-javap_additional_option.patch
@@ -0,0 +1,288 @@
+# HG changeset patch
+# User jjg
+# Date 1217897655 25200
+# Mon Aug 04 17:54:15 2008 -0700
+# Node ID dca34170f5f80bf30228c12a647b3f1a492b3eeb
+# Parent 6134c146043a3e9dd12ee73ca32ce56ac1c95e3a
+4884240: additional option required for javap
+Reviewed-by: ksrini
+
+diff -r 6134c146043a -r dca34170f5f8 src/share/classes/com/sun/tools/javap/ClassWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon Aug 04 15:09:02 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon Aug 04 17:54:15 2008 -0700
+@@ -25,6 +25,7 @@
+
+ package com.sun.tools.javap;
+
++import java.net.URI;
+ import java.util.Collection;
+ import java.util.List;
+
+@@ -46,6 +47,8 @@
+ import com.sun.tools.classfile.SourceFile_attribute;
+ import com.sun.tools.classfile.Type;
+
++import java.text.DateFormat;
++import java.util.Date;
+ import static com.sun.tools.classfile.AccessFlags.*;
+
+ /*
+@@ -73,6 +76,23 @@
+ constantWriter = ConstantWriter.instance(context);
+ }
+
++ void setDigest(String name, byte[] digest) {
++ this.digestName = name;
++ this.digest = digest;
++ }
++
++ void setFile(URI uri) {
++ this.uri = uri;
++ }
++
++ void setFileSize(int size) {
++ this.size = size;
++ }
++
++ void setLastModified(long lastModified) {
++ this.lastModified = lastModified;
++ }
++
+ ClassFile getClassFile() {
+ return classFile;
+ }
+@@ -85,6 +105,32 @@
+ classFile = cf;
+ constant_pool = classFile.constant_pool;
+
++ if ((options.sysInfo || options.verbose) && !options.compat) {
++ if (uri != null) {
++ if (uri.getScheme().equals("file"))
++ println("Classfile " + uri.getPath());
++ else
++ println("Classfile " + uri);
++ }
++ if (lastModified != -1) {
++ Date lm = new Date(lastModified);
++ DateFormat df = DateFormat.getDateInstance();
++ if (size > 0) {
++ println("Last modified " + df.format(lm) + "; size " + size + " bytes");
++ } else {
++ println("Last modified " + df.format(lm));
++ }
++ } else if (size > 0) {
++ println("Size " + size + " bytes");
++ }
++ if (digestName != null && digest != null) {
++ StringBuilder sb = new StringBuilder();
++ for (byte b: digest)
++ sb.append(String.format("%02x", b));
++ println(digestName + " checksum " + sb);
++ }
++ }
++
+ Attribute sfa = cf.getAttribute(Attribute.SourceFile);
+ if (sfa instanceof SourceFile_attribute) {
+ println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\"");
+@@ -574,6 +620,11 @@
+ private CodeWriter codeWriter;
+ private ConstantWriter constantWriter;
+ private ClassFile classFile;
++ private URI uri;
++ private long lastModified;
++ private String digestName;
++ private byte[] digest;
++ private int size;
+ private ConstantPool constant_pool;
+ private Method method;
+ private static final String NEWLINE = System.getProperty("line.separator", "\n");
+diff -r 6134c146043a -r dca34170f5f8 src/share/classes/com/sun/tools/javap/JavapTask.java
+--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Aug 04 15:09:02 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Aug 04 17:54:15 2008 -0700
+@@ -27,11 +27,15 @@
+
+ import java.io.EOFException;
+ import java.io.FileNotFoundException;
++import java.io.FilterInputStream;
++import java.io.InputStream;
+ import java.io.IOException;
+ import java.io.OutputStream;
+ import java.io.PrintWriter;
+ import java.io.StringWriter;
+ import java.io.Writer;
++import java.security.DigestInputStream;
++import java.security.MessageDigest;
+ import java.text.MessageFormat;
+ import java.util.ArrayList;
+ import java.util.Arrays;
+@@ -192,6 +196,12 @@
+ }
+ },
+
++ new Option(false, "-sysinfo") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.sysInfo = true;
++ }
++ },
++
+ new Option(false, "-Xold") {
+ void process(JavapTask task, String opt, String arg) throws BadArgs {
+ // -Xold is only supported as first arg when invoked from
+@@ -457,8 +467,27 @@
+ Attribute.Factory attributeFactory = new Attribute.Factory();
+ attributeFactory.setCompat(options.compat);
+ attributeFactory.setJSR277(options.jsr277);
+- ClassFile cf = ClassFile.read(fo.openInputStream(), attributeFactory);
++
++ InputStream in = fo.openInputStream();
++ SizeInputStream sizeIn = null;
++ MessageDigest md = null;
++ if (options.sysInfo || options.verbose) {
++ md = MessageDigest.getInstance("MD5");
++ in = new DigestInputStream(in, md);
++ in = sizeIn = new SizeInputStream(in);
++ }
++
++ ClassFile cf = ClassFile.read(in, attributeFactory);
++
++ if (options.sysInfo || options.verbose) {
++ classWriter.setFile(fo.toUri());
++ classWriter.setLastModified(fo.getLastModified());
++ classWriter.setDigest("MD5", md.digest());
++ classWriter.setFileSize(sizeIn.size());
++ }
++
+ classWriter.write(cf);
++
+ } catch (ConstantPoolException e) {
+ diagnosticListener.report(createDiagnostic("err.bad.constant.pool", className, e.getLocalizedMessage()));
+ ok = false;
+@@ -628,4 +657,31 @@
+ Map<Locale, ResourceBundle> bundles;
+
+ private static final String progname = "javap";
++
++ private static class SizeInputStream extends FilterInputStream {
++ SizeInputStream(InputStream in) {
++ super(in);
++ }
++
++ int size() {
++ return size;
++ }
++
++ @Override
++ public int read(byte[] buf, int offset, int length) throws IOException {
++ int n = super.read(buf, offset, length);
++ if (n > 0)
++ size += n;
++ return n;
++ }
++
++ @Override
++ public int read() throws IOException {
++ int b = super.read();
++ size += 1;
++ return b;
++ }
++
++ private int size;
++ }
+ }
+diff -r 6134c146043a -r dca34170f5f8 src/share/classes/com/sun/tools/javap/Options.java
+--- langtools/src/share/classes/com/sun/tools/javap/Options.java Mon Aug 04 15:09:02 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/Options.java Mon Aug 04 17:54:15 2008 -0700
+@@ -78,6 +78,7 @@
+ public boolean showInternalSignatures;
+ public boolean showAllAttrs;
+ public boolean showConstants;
++ public boolean sysInfo;
+
+ public boolean compat; // bug-for-bug compatibility mode with old javap
+ public boolean jsr277;
+diff -r 6134c146043a -r dca34170f5f8 src/share/classes/com/sun/tools/javap/resources/javap.properties
+--- langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Mon Aug 04 15:09:02 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Mon Aug 04 17:54:15 2008 -0700
+@@ -62,5 +62,6 @@
+ \ -constants Show static final constants
+
+
+-
+-
++main.opt.sysinfo=\
++\ -sysinfo Show system info (path, size, date, MD5 hash)\n\
++\ of class being processed
+diff -r 6134c146043a -r dca34170f5f8 test/tools/javap/T4884240.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T4884240.java Mon Aug 04 17:54:15 2008 -0700
+@@ -0,0 +1,56 @@
++/*
++ * 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-15301 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 4884240
++ * @summary additional option required for javap
++ */
++
++import java.io.*;
++
++public class T4884240 {
++ public static void main(String... args) throws Exception {
++ new T4884240().run();
++ }
++
++ public void run() throws Exception {
++ StringWriter sw = new StringWriter();
++ PrintWriter pw = new PrintWriter(sw);
++ String[] args = { "-sysinfo", "java.lang.Object" };
++ int rc = com.sun.tools.javap.Main.run(args, pw);
++ if (rc != 0)
++ throw new Exception("unexpected return code: " + rc);
++ pw.close();
++ String[] lines = sw.toString().split("\n");
++ if (lines.length < 3
++ || !lines[0].startsWith("Classfile")
++ || !lines[1].startsWith("Last modified")
++ || !lines[2].startsWith("MD5")) {
++ System.out.println(sw);
++ throw new Exception("unexpected output");
++ }
++ }
++}
+diff -r 6134c146043a -r dca34170f5f8 test/tools/javap/T6622260.java
+--- langtools/test/tools/javap/T6622260.java Mon Aug 04 15:09:02 2008 -0700
++++ langtools/test/tools/javap/T6622260.java Mon Aug 04 17:54:15 2008 -0700
+@@ -189,6 +189,10 @@
+
+ void verify(String output) {
+ System.out.println(output);
++ if (output.startsWith("Classfile")) {
++ // make sure to ignore filename
++ output = output.substring(output.indexOf('\n'));
++ }
+ if (output.indexOf("-") >= 0)
+ throw new Error("- found in output");
+ if (output.indexOf("FFFFFF") >= 0)
diff --git a/java/openjdk6/files/icedtea/openjdk/6708729-javap_makefile_update.patch b/java/openjdk6/files/icedtea/openjdk/6708729-javap_makefile_update.patch
new file mode 100644
index 000000000000..5851532b415c
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6708729-javap_makefile_update.patch
@@ -0,0 +1,59 @@
+# HG changeset patch
+# User jjg
+# Date 1212524896 25200
+# Tue Jun 03 13:28:16 2008 -0700
+# Node ID 566f427de7079a0ed32c2f625c952dcc45c348e3
+# Parent d206cb658a9907c7842c8920f141b3c4eb5efc1f
+6708729: update jdk Makefiles for new javap
+Reviewed-by: ohair
+
+diff -r d206cb658a99 -r 566f427de707 make/common/Release.gmk
+--- jdk/make/common/Release.gmk Mon Oct 21 18:05:56 2013 +0100
++++ jdk/make/common/Release.gmk Tue Jun 03 13:28:16 2008 -0700
+@@ -357,6 +357,7 @@
+ com/sun/jarsigner \
+ com/sun/mirror \
+ com/sun/source \
++ com/sun/tools/classfile \
+ com/sun/tools/doclets \
+ com/sun/tools/example/debug/expr \
+ com/sun/tools/example/debug/tty \
+@@ -366,6 +367,7 @@
+ com/sun/tools/javadoc \
+ com/sun/tools/apt \
+ com/sun/tools/javah \
++ com/sun/tools/javap \
+ com/sun/tools/corba \
+ com/sun/tools/internal/xjc \
+ com/sun/tools/internal/ws \
+@@ -558,6 +560,8 @@
+ $(ECHO) "sun/tools/java/" >> $@
+ $(ECHO) "sun/tools/javac/" >> $@
+ $(ECHO) "sun/tools/javap/" >> $@
++ $(ECHO) "com/sun/tools/classfile/" >> $@
++ $(ECHO) "com/sun/tools/javap/" >> $@
+ $(ECHO) "sun/tools/jconsole/" >> $@
+ $(ECHO) "sun/tools/jps/" >> $@
+ $(ECHO) "sun/tools/jstat/" >> $@
+diff -r d206cb658a99 -r 566f427de707 make/common/internal/Defs-langtools.gmk
+--- jdk/make/common/internal/Defs-langtools.gmk Mon Oct 21 18:05:56 2013 +0100
++++ jdk/make/common/internal/Defs-langtools.gmk Tue Jun 03 13:28:16 2008 -0700
+@@ -31,13 +31,15 @@
+ javax/tools
+
+ IMPORT_TOOLS_PACKAGES += \
++ com/sun/javadoc \
+ com/sun/mirror \
+ com/sun/source \
+ com/sun/tools/apt \
++ com/sun/tools/classfile \
++ com/sun/tools/doclets \
+ com/sun/tools/javac \
++ com/sun/tools/javadoc \
+ com/sun/tools/javah \
+- com/sun/tools/javadoc \
+- com/sun/tools/doclets \
+- com/sun/javadoc \
++ com/sun/tools/javap \
+ sun/tools/javap
+
diff --git a/java/openjdk6/files/icedtea/openjdk/6715767-javap_crash.patch b/java/openjdk6/files/icedtea/openjdk/6715767-javap_crash.patch
new file mode 100644
index 000000000000..37713f727176
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6715767-javap_crash.patch
@@ -0,0 +1,135 @@
+# HG changeset patch
+# User jjg
+# Date 1213833188 25200
+# Wed Jun 18 16:53:08 2008 -0700
+# Node ID c9b0fee44d446f902102462387c40ca9d1020b6e
+# Parent 3cbaa3d49584846d4fd8459edeb696b02de5499b
+6715767: javap on java.lang.ClassLoader crashes
+Reviewed-by: ksrini
+
+diff -r 3cbaa3d49584 -r c9b0fee44d44 src/share/classes/com/sun/tools/classfile/ConstantPool.java
+--- langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Thu Oct 24 02:40:06 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Wed Jun 18 16:53:08 2008 -0700
+@@ -153,7 +153,7 @@
+ break;
+
+ case CONSTANT_String:
+- pool[i] = new CONSTANT_String_info(cr);
++ pool[i] = new CONSTANT_String_info(this, cr);
+ break;
+
+ case CONSTANT_Utf8:
+@@ -509,7 +509,8 @@
+ }
+
+ public static class CONSTANT_String_info extends CPInfo {
+- CONSTANT_String_info(ClassReader cr) throws IOException {
++ CONSTANT_String_info(ConstantPool cp, ClassReader cr) throws IOException {
++ super(cp);
+ string_index = cr.readUnsignedShort();
+ }
+
+diff -r 3cbaa3d49584 -r c9b0fee44d44 src/share/classes/com/sun/tools/javap/AttributeWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Thu Oct 24 02:40:06 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Wed Jun 18 16:53:08 2008 -0700
+@@ -259,7 +259,7 @@
+ return null;
+ }
+
+- String getJavaException(Exceptions_attribute attr, int index) {
++ private String getJavaException(Exceptions_attribute attr, int index) {
+ try {
+ return getJavaName(attr.getException(index, constant_pool));
+ } catch (ConstantPoolException e) {
+diff -r 3cbaa3d49584 -r c9b0fee44d44 src/share/classes/com/sun/tools/javap/ClassWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Thu Oct 24 02:40:06 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Wed Jun 18 16:53:08 2008 -0700
+@@ -291,7 +291,7 @@
+ for (int i = 0; i < exceptions.number_of_exceptions; i++) {
+ if (i > 0)
+ print(", ");
+- print(attrWriter.getJavaException(exceptions, i));
++ print(getJavaException(exceptions, i));
+ }
+ }
+ } else {
+@@ -441,6 +441,14 @@
+ }
+ }
+
++ String getJavaException(Exceptions_attribute attr, int index) {
++ try {
++ return getJavaName(attr.getException(index, constant_pool));
++ } catch (ConstantPoolException e) {
++ return report(e);
++ }
++ }
++
+ String getValue(Descriptor d) {
+ try {
+ return d.getValue(constant_pool);
+diff -r 3cbaa3d49584 -r c9b0fee44d44 src/share/classes/com/sun/tools/javap/JavapTask.java
+--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Thu Oct 24 02:40:06 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Wed Jun 18 16:53:08 2008 -0700
+@@ -475,6 +475,7 @@
+ t.printStackTrace(pw);
+ pw.close();
+ diagnosticListener.report(createDiagnostic("err.crash", t.toString(), sw.toString()));
++ ok = false;
+ }
+ }
+
+diff -r 3cbaa3d49584 -r c9b0fee44d44 test/tools/javap/T6715767.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T6715767.java Wed Jun 18 16:53:08 2008 -0700
+@@ -0,0 +1,50 @@
++/*
++ * 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 6715767
++ * @summary javap on java.lang.ClassLoader crashes
++ */
++
++import java.io.*;
++
++public class T6715767 {
++ public static void main(String... args) throws Exception {
++ new T6715767().run();
++ }
++
++ void run() throws Exception {
++ StringWriter sw = new StringWriter();
++ PrintWriter pw = new PrintWriter(sw);
++ String[] args = { "java.lang.ClassLoader" };
++ int rc = com.sun.tools.javap.Main.run(args, pw);
++ if (rc != 0 ||
++ sw.toString().indexOf("at com.sun.tools.javap.JavapTask.run") != -1) {
++ System.err.println("rc: " + rc);
++ System.err.println("log:\n" + sw);
++ throw new Exception("unexpected result");
++ }
++ }
++}
++
diff --git a/java/openjdk6/files/icedtea/openjdk/6819246-javap_instruction_decoding.patch b/java/openjdk6/files/icedtea/openjdk/6819246-javap_instruction_decoding.patch
new file mode 100644
index 000000000000..70b7d6cc2eae
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6819246-javap_instruction_decoding.patch
@@ -0,0 +1,2065 @@
+# HG changeset patch
+# User jjg
+# Date 1382578806 -3600
+# Thu Oct 24 02:40:06 2013 +0100
+# Node ID 3cbaa3d49584846d4fd8459edeb696b02de5499b
+# Parent bfd7bb4218253bac4f57abbc90b987f16e4b7f6c
+6819246: improve support for decoding instructions in classfile library
+Reviewed-by: ksrini
+
+diff -r bfd7bb421825 -r 3cbaa3d49584 src/share/classes/com/sun/tools/classfile/Code_attribute.java
+--- langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java Tue Oct 22 01:03:49 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java Thu Oct 24 02:40:06 2013 +0100
+@@ -26,6 +26,8 @@
+ package com.sun.tools.classfile;
+
+ import java.io.IOException;
++import java.util.Iterator;
++import java.util.NoSuchElementException;
+
+ /**
+ * See JVMS3, section 4.8.3.
+@@ -99,6 +101,39 @@
+ return visitor.visitCode(this, data);
+ }
+
++ public Iterable<Instruction> getInstructions() {
++ return new Iterable<Instruction>() {
++ public Iterator<Instruction> iterator() {
++ return new Iterator<Instruction>() {
++
++ public boolean hasNext() {
++ return (next != null);
++ }
++
++ public Instruction next() {
++ if (next == null)
++ throw new NoSuchElementException();
++
++ current = next;
++ pc += current.length();
++ next = (pc < code.length ? new Instruction(code, pc) : null);
++ return current;
++ }
++
++ public void remove() {
++ throw new UnsupportedOperationException("Not supported.");
++ }
++
++ Instruction current = null;
++ int pc = 0;
++ Instruction next = new Instruction(code, pc);
++
++ };
++ }
++
++ };
++ }
++
+ public final int max_stack;
+ public final int max_locals;
+ public final int code_length;
+diff -r bfd7bb421825 -r 3cbaa3d49584 src/share/classes/com/sun/tools/classfile/Instruction.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Instruction.java Thu Oct 24 02:40:06 2013 +0100
+@@ -0,0 +1,339 @@
++/*
++ * 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 com.sun.tools.classfile;
++
++/**
++ * See JVMS3, chapter 6.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ *
++ * @see Code_attribute#getInstructions
++ */
++public class Instruction {
++ /** The kind of an instruction, as determined by the position, size and
++ * types of its operands. */
++ public static enum Kind {
++ /** Opcode is not followed by any operands. */
++ NO_OPERANDS(1),
++ /** Opcode is followed by a byte indicating a type. */
++ ATYPE(2),
++ /** Opcode is followed by a 2-byte branch offset. */
++ BRANCH(3),
++ /** Opcode is followed by a 4-byte branch offset. */
++ BRANCH_W(5),
++ /** Opcode is followed by a signed byte value. */
++ BYTE(2),
++ /** Opcode is followed by a 1-byte index into the constant pool. */
++ CPREF(2),
++ /** Opcode is followed by a 2-byte index into the constant pool. */
++ CPREF_W(3),
++ /** Opcode is followed by a 2-byte index into the constant pool,
++ * an unsigned byte value. */
++ CPREF_W_UBYTE(4),
++ /** Opcode is followed by a 2-byte index into the constant pool.,
++ * an unsigned byte value, and a zero byte. */
++ CPREF_W_UBYTE_ZERO(5),
++ /** Opcode is followed by variable number of operands, depending
++ * on the instruction.*/
++ DYNAMIC(-1),
++ /** Opcode is followed by a 1-byte reference to a local variable. */
++ LOCAL(2),
++ /** Opcode is followed by a 1-byte reference to a local variable,
++ * and a signed byte value. */
++ LOCAL_BYTE(3),
++ /** Opcode is followed by a signed short value. */
++ SHORT(3),
++ /** Wide opcode is not followed by any operands. */
++ WIDE_NO_OPERANDS(2),
++ /** Wide opcode is followed by a 2-byte index into the constant pool. */
++ WIDE_CPREF_W(4),
++ /** Wide opcode is followed by a 2-byte index into the constant pool,
++ * and a signed short value. */
++ WIDE_CPREF_W_SHORT(6),
++ /** Opcode was not recognized. */
++ UNKNOWN(1);
++
++ Kind(int length) {
++ this.length = length;
++ }
++
++ /** The length, in bytes, of this kind of instruction, or -1 is the
++ * length depends on the specific instruction. */
++ public final int length;
++ };
++
++ /** A utility visitor to help decode the operands of an instruction.
++ * @see Instruction#accept */
++ public interface KindVisitor<R,P> {
++ /** See {@link Kind#NO_OPERANDS}, {@link Kind#WIDE_NO_OPERANDS}. */
++ R visitNoOperands(Instruction instr, P p);
++ /** See {@link Kind#ATYPE}. */
++ R visitArrayType(Instruction instr, TypeKind kind, P p);
++ /** See {@link Kind#BRANCH}, {@link Kind#BRANCH_W}. */
++ R visitBranch(Instruction instr, int offset, P p);
++ /** See {@link Kind#CPREF}, {@link Kind#CPREF_W}, {@link Kind#WIDE_CPREF_W}. */
++ R visitConstantPoolRef(Instruction instr, int index, P p);
++ /** See {@link Kind#CPREF_W_UBYTE}, {@link Kind#CPREF_W_UBYTE_ZERO}, {@link Kind#WIDE_CPREF_W_SHORT}. */
++ R visitConstantPoolRefAndValue(Instruction instr, int index, int value, P p);
++ /** See {@link Kind#LOCAL}. */
++ R visitLocal(Instruction instr, int index, P p);
++ /** See {@link Kind#LOCAL_UBYTE}. */
++ R visitLocalAndValue(Instruction instr, int index, int value, P p);
++ /** See {@link Kind#DYNAMIC}. */
++ R visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets);
++ /** See {@link Kind#DYNAMIC}. */
++ R visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets);
++ /** See {@link Kind#BYTE}, {@link Kind#SHORT}. */
++ R visitValue(Instruction instr, int value, P p);
++ /** Instruction is unrecognized. */
++ R visitUnknown(Instruction instr, P p);
++
++ }
++
++ /** The kind of primitive array type to create.
++ * See JVMS chapter 6, newarray. */
++ public static enum TypeKind {
++ T_BOOLEAN(4, "boolean"),
++ T_CHAR(5, "char"),
++ T_FLOAT(6, "float"),
++ T_DOUBLE(7, "double"),
++ T_BYTE(8, "byte"),
++ T_SHORT(9, "short"),
++ T_INT (10, "int"),
++ T_LONG (11, "long");
++ TypeKind(int value, String name) {
++ this.value = value;
++ this.name = name;
++ }
++
++ public static TypeKind get(int value) {
++ switch (value) {
++ case 4: return T_BOOLEAN;
++ case 5: return T_CHAR;
++ case 6: return T_FLOAT;
++ case 7: return T_DOUBLE;
++ case 8: return T_BYTE;
++ case 9: return T_SHORT;
++ case 10: return T_INT;
++ case 11: return T_LONG;
++ default: return null;
++ }
++ }
++
++ public final int value;
++ public final String name;
++ }
++
++ /** An instruction is defined by its position in a bytecode array. */
++ public Instruction(byte[] bytes, int pc) {
++ this.bytes = bytes;
++ this.pc = pc;
++ }
++
++ /** Get the position of the instruction within the bytecode array. */
++ public int getPC() {
++ return pc;
++ }
++
++ /** Get a byte value, relative to the start of this instruction. */
++ public int getByte(int offset) {
++ return bytes[pc + offset];
++ }
++
++ /** Get an unsigned byte value, relative to the start of this instruction. */
++ public int getUnsignedByte(int offset) {
++ return getByte(offset) & 0xff;
++ }
++
++ /** Get a 2-byte value, relative to the start of this instruction. */
++ public int getShort(int offset) {
++ return (getByte(offset) << 8) | getUnsignedByte(offset + 1);
++ }
++
++ /** Get a unsigned 2-byte value, relative to the start of this instruction. */
++ public int getUnsignedShort(int offset) {
++ return getShort(offset) & 0xFFFF;
++ }
++
++ /** Get a 4-byte value, relative to the start of this instruction. */
++ public int getInt(int offset) {
++ return (getShort(offset) << 16) | (getUnsignedShort(offset + 2));
++ }
++
++ /** Get the Opcode for this instruction, or null if the instruction is
++ * unrecognized. */
++ public Opcode getOpcode() {
++ int b = getUnsignedByte(0);
++ switch (b) {
++ case Opcode.NONPRIV:
++ case Opcode.PRIV:
++ case Opcode.WIDE:
++ return Opcode.get(b, getUnsignedByte(1));
++ }
++ return Opcode.get(b);
++ }
++
++ /** Get the mnemonic for this instruction, or a default string if the
++ * instruction is unrecognized. */
++ public String getMnemonic() {
++ Opcode opcode = getOpcode();
++ if (opcode == null)
++ return "bytecode " + getUnsignedByte(0);
++ else
++ return opcode.toString().toLowerCase();
++ }
++
++ /** Get the length, in bytes, of this instruction, including the opcode
++ * and all its operands. */
++ public int length() {
++ Opcode opcode = getOpcode();
++ if (opcode == null)
++ return 1;
++
++ switch (opcode) {
++ case TABLESWITCH: {
++ int pad = align(pc + 1) - pc;
++ int low = getInt(pad + 4);
++ int high = getInt(pad + 8);
++ return pad + 12 + 4 * (high - low + 1);
++ }
++ case LOOKUPSWITCH: {
++ int pad = align(pc + 1) - pc;
++ int npairs = getInt(pad + 4);
++ return pad + 8 + 8 * npairs;
++
++ }
++ default:
++ return opcode.kind.length;
++ }
++ }
++
++ /** Get the {@link Kind} of this instruction. */
++ public Kind getKind() {
++ Opcode opcode = getOpcode();
++ return (opcode != null ? opcode.kind : Kind.UNKNOWN);
++ }
++
++ /** Invoke a method on the visitor according to the kind of this
++ * instruction, passing in the decoded operands for the instruction. */
++ public <R,P> R accept(KindVisitor<R,P> visitor, P p) {
++ switch (getKind()) {
++ case NO_OPERANDS:
++ return visitor.visitNoOperands(this, p);
++
++ case ATYPE:
++ return visitor.visitArrayType(
++ this, TypeKind.get(getUnsignedByte(1)), p);
++
++ case BRANCH:
++ return visitor.visitBranch(this, getShort(1), p);
++
++ case BRANCH_W:
++ return visitor.visitBranch(this, getInt(1), p);
++
++ case BYTE:
++ return visitor.visitValue(this, getByte(1), p);
++
++ case CPREF:
++ return visitor.visitConstantPoolRef(this, getUnsignedByte(1), p);
++
++ case CPREF_W:
++ return visitor.visitConstantPoolRef(this, getUnsignedShort(1), p);
++
++ case CPREF_W_UBYTE:
++ case CPREF_W_UBYTE_ZERO:
++ return visitor.visitConstantPoolRefAndValue(
++ this, getUnsignedShort(1), getUnsignedByte(3), p);
++
++ case DYNAMIC: {
++ switch (getOpcode()) {
++ case TABLESWITCH: {
++ int pad = align(pc + 1) - pc;
++ int default_ = getInt(pad);
++ int low = getInt(pad + 4);
++ int high = getInt(pad + 8);
++ int[] values = new int[high - low + 1];
++ for (int i = 0; i < values.length; i++)
++ values[i] = getInt(pad + 12 + 4 * i);
++ return visitor.visitTableSwitch(
++ this, default_, low, high, values);
++ }
++ case LOOKUPSWITCH: {
++ int pad = align(pc + 1) - pc;
++ int default_ = getInt(pad);
++ int npairs = getInt(pad + 4);
++ int[] matches = new int[npairs];
++ int[] offsets = new int[npairs];
++ for (int i = 0; i < npairs; i++) {
++ matches[i] = getInt(pad + 8 + i * 8);
++ offsets[i] = getInt(pad + 12 + i * 8);
++ }
++ return visitor.visitLookupSwitch(
++ this, default_, npairs, matches, offsets);
++ }
++ default:
++ throw new IllegalStateException();
++ }
++ }
++
++ case LOCAL:
++ return visitor.visitLocal(this, getUnsignedByte(1), p);
++
++ case LOCAL_BYTE:
++ return visitor.visitLocalAndValue(
++ this, getUnsignedByte(1), getByte(2), p);
++
++ case SHORT:
++ return visitor.visitValue(this, getShort(1), p);
++
++ case WIDE_NO_OPERANDS:
++ return visitor.visitNoOperands(this, p);
++
++ case WIDE_CPREF_W:
++ return visitor.visitConstantPoolRef(this, getUnsignedShort(2), p);
++
++ case WIDE_CPREF_W_SHORT:
++ return visitor.visitConstantPoolRefAndValue(
++ this, getUnsignedShort(2), getUnsignedByte(4), p);
++
++ case UNKNOWN:
++ return visitor.visitUnknown(this, p);
++
++ default:
++ throw new IllegalStateException();
++ }
++ }
++
++ private static int align(int n) {
++ return (n + 3) & ~3;
++ }
++
++ private byte[] bytes;
++ private int pc;
++}
+diff -r bfd7bb421825 -r 3cbaa3d49584 src/share/classes/com/sun/tools/classfile/OpCodes.java
+--- langtools/src/share/classes/com/sun/tools/classfile/OpCodes.java Tue Oct 22 01:03:49 2013 +0100
++++ /dev/null Thu Jan 01 00:00:00 1970 +0000
+@@ -1,868 +0,0 @@
+-/*
+- * Copyright 2007 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 com.sun.tools.classfile;
+-
+-import java.util.HashMap;
+-
+-/**
+- * See JVMS3, section 6.
+- *
+- * <p><b>This is NOT part of any API supported by Sun Microsystems. If
+- * you write code that depends on this, you do so at your own risk.
+- * This code and its internal interfaces are subject to change or
+- * deletion without notice.</b>
+- */
+-public class OpCodes {
+-
+- public static int opcLength(int opc) throws IllegalArgumentException {
+- switch (opc >> 8) {
+- case 0:
+- return opcLengthsTab[opc];
+- case opc_wide:
+- switch (opc & 0xFF) {
+- case opc_aload:
+- case opc_astore:
+- case opc_fload:
+- case opc_fstore:
+- case opc_iload:
+- case opc_istore:
+- case opc_lload:
+- case opc_lstore:
+- case opc_dload:
+- case opc_dstore:
+- case opc_ret:
+- return 4;
+- case opc_iinc:
+- return 6;
+- default:
+- throw new IllegalArgumentException();
+- }
+- case opc_nonpriv:
+- case opc_priv:
+- return 2;
+- default:
+- throw new IllegalArgumentException();
+- }
+- }
+-
+- public static String opcName(int opc) {
+- try {
+- switch (opc >> 8) {
+- case 0:
+- return opcNamesTab[opc];
+- case opc_wide:
+- {
+- String mnem = opcNamesTab[opc & 0xFF] + "_w";
+- if (mnemocodes.get(mnem) == null) {
+- return null; // non-existent opcode
+- }
+- return mnem;
+- }
+- case opc_nonpriv:
+- return opcExtNamesTab[opc & 0xFF];
+- case opc_priv:
+- return opcPrivExtNamesTab[opc & 0xFF];
+- default:
+- return null;
+- }
+- } catch (ArrayIndexOutOfBoundsException e) {
+- switch (opc) {
+- case opc_nonpriv:
+- return "nonpriv";
+- case opc_priv:
+- return "priv";
+- default:
+- return null;
+- }
+- }
+- }
+-
+- /* Opcodes */
+- public static final int opc_dead = -2;
+- public static final int opc_label = -1;
+- public static final int opc_nop = 0;
+- public static final int opc_aconst_null = 1;
+- public static final int opc_iconst_m1 = 2;
+- public static final int opc_iconst_0 = 3;
+- public static final int opc_iconst_1 = 4;
+- public static final int opc_iconst_2 = 5;
+- public static final int opc_iconst_3 = 6;
+- public static final int opc_iconst_4 = 7;
+- public static final int opc_iconst_5 = 8;
+- public static final int opc_lconst_0 = 9;
+- public static final int opc_lconst_1 = 10;
+- public static final int opc_fconst_0 = 11;
+- public static final int opc_fconst_1 = 12;
+- public static final int opc_fconst_2 = 13;
+- public static final int opc_dconst_0 = 14;
+- public static final int opc_dconst_1 = 15;
+- public static final int opc_bipush = 16;
+- public static final int opc_sipush = 17;
+- public static final int opc_ldc = 18;
+- public static final int opc_ldc_w = 19;
+- public static final int opc_ldc2_w = 20;
+- public static final int opc_iload = 21;
+- public static final int opc_lload = 22;
+- public static final int opc_fload = 23;
+- public static final int opc_dload = 24;
+- public static final int opc_aload = 25;
+- public static final int opc_iload_0 = 26;
+- public static final int opc_iload_1 = 27;
+- public static final int opc_iload_2 = 28;
+- public static final int opc_iload_3 = 29;
+- public static final int opc_lload_0 = 30;
+- public static final int opc_lload_1 = 31;
+- public static final int opc_lload_2 = 32;
+- public static final int opc_lload_3 = 33;
+- public static final int opc_fload_0 = 34;
+- public static final int opc_fload_1 = 35;
+- public static final int opc_fload_2 = 36;
+- public static final int opc_fload_3 = 37;
+- public static final int opc_dload_0 = 38;
+- public static final int opc_dload_1 = 39;
+- public static final int opc_dload_2 = 40;
+- public static final int opc_dload_3 = 41;
+- public static final int opc_aload_0 = 42;
+- public static final int opc_aload_1 = 43;
+- public static final int opc_aload_2 = 44;
+- public static final int opc_aload_3 = 45;
+- public static final int opc_iaload = 46;
+- public static final int opc_laload = 47;
+- public static final int opc_faload = 48;
+- public static final int opc_daload = 49;
+- public static final int opc_aaload = 50;
+- public static final int opc_baload = 51;
+- public static final int opc_caload = 52;
+- public static final int opc_saload = 53;
+- public static final int opc_istore = 54;
+- public static final int opc_lstore = 55;
+- public static final int opc_fstore = 56;
+- public static final int opc_dstore = 57;
+- public static final int opc_astore = 58;
+- public static final int opc_istore_0 = 59;
+- public static final int opc_istore_1 = 60;
+- public static final int opc_istore_2 = 61;
+- public static final int opc_istore_3 = 62;
+- public static final int opc_lstore_0 = 63;
+- public static final int opc_lstore_1 = 64;
+- public static final int opc_lstore_2 = 65;
+- public static final int opc_lstore_3 = 66;
+- public static final int opc_fstore_0 = 67;
+- public static final int opc_fstore_1 = 68;
+- public static final int opc_fstore_2 = 69;
+- public static final int opc_fstore_3 = 70;
+- public static final int opc_dstore_0 = 71;
+- public static final int opc_dstore_1 = 72;
+- public static final int opc_dstore_2 = 73;
+- public static final int opc_dstore_3 = 74;
+- public static final int opc_astore_0 = 75;
+- public static final int opc_astore_1 = 76;
+- public static final int opc_astore_2 = 77;
+- public static final int opc_astore_3 = 78;
+- public static final int opc_iastore = 79;
+- public static final int opc_lastore = 80;
+- public static final int opc_fastore = 81;
+- public static final int opc_dastore = 82;
+- public static final int opc_aastore = 83;
+- public static final int opc_bastore = 84;
+- public static final int opc_castore = 85;
+- public static final int opc_sastore = 86;
+- public static final int opc_pop = 87;
+- public static final int opc_pop2 = 88;
+- public static final int opc_dup = 89;
+- public static final int opc_dup_x1 = 90;
+- public static final int opc_dup_x2 = 91;
+- public static final int opc_dup2 = 92;
+- public static final int opc_dup2_x1 = 93;
+- public static final int opc_dup2_x2 = 94;
+- public static final int opc_swap = 95;
+- public static final int opc_iadd = 96;
+- public static final int opc_ladd = 97;
+- public static final int opc_fadd = 98;
+- public static final int opc_dadd = 99;
+- public static final int opc_isub = 100;
+- public static final int opc_lsub = 101;
+- public static final int opc_fsub = 102;
+- public static final int opc_dsub = 103;
+- public static final int opc_imul = 104;
+- public static final int opc_lmul = 105;
+- public static final int opc_fmul = 106;
+- public static final int opc_dmul = 107;
+- public static final int opc_idiv = 108;
+- public static final int opc_ldiv = 109;
+- public static final int opc_fdiv = 110;
+- public static final int opc_ddiv = 111;
+- public static final int opc_irem = 112;
+- public static final int opc_lrem = 113;
+- public static final int opc_frem = 114;
+- public static final int opc_drem = 115;
+- public static final int opc_ineg = 116;
+- public static final int opc_lneg = 117;
+- public static final int opc_fneg = 118;
+- public static final int opc_dneg = 119;
+- public static final int opc_ishl = 120;
+- public static final int opc_lshl = 121;
+- public static final int opc_ishr = 122;
+- public static final int opc_lshr = 123;
+- public static final int opc_iushr = 124;
+- public static final int opc_lushr = 125;
+- public static final int opc_iand = 126;
+- public static final int opc_land = 127;
+- public static final int opc_ior = 128;
+- public static final int opc_lor = 129;
+- public static final int opc_ixor = 130;
+- public static final int opc_lxor = 131;
+- public static final int opc_iinc = 132;
+- public static final int opc_i2l = 133;
+- public static final int opc_i2f = 134;
+- public static final int opc_i2d = 135;
+- public static final int opc_l2i = 136;
+- public static final int opc_l2f = 137;
+- public static final int opc_l2d = 138;
+- public static final int opc_f2i = 139;
+- public static final int opc_f2l = 140;
+- public static final int opc_f2d = 141;
+- public static final int opc_d2i = 142;
+- public static final int opc_d2l = 143;
+- public static final int opc_d2f = 144;
+- public static final int opc_i2b = 145;
+- public static final int opc_int2byte = 145;
+- public static final int opc_i2c = 146;
+- public static final int opc_int2char = 146;
+- public static final int opc_i2s = 147;
+- public static final int opc_int2short = 147;
+- public static final int opc_lcmp = 148;
+- public static final int opc_fcmpl = 149;
+- public static final int opc_fcmpg = 150;
+- public static final int opc_dcmpl = 151;
+- public static final int opc_dcmpg = 152;
+- public static final int opc_ifeq = 153;
+- public static final int opc_ifne = 154;
+- public static final int opc_iflt = 155;
+- public static final int opc_ifge = 156;
+- public static final int opc_ifgt = 157;
+- public static final int opc_ifle = 158;
+- public static final int opc_if_icmpeq = 159;
+- public static final int opc_if_icmpne = 160;
+- public static final int opc_if_icmplt = 161;
+- public static final int opc_if_icmpge = 162;
+- public static final int opc_if_icmpgt = 163;
+- public static final int opc_if_icmple = 164;
+- public static final int opc_if_acmpeq = 165;
+- public static final int opc_if_acmpne = 166;
+- public static final int opc_goto = 167;
+- public static final int opc_jsr = 168;
+- public static final int opc_ret = 169;
+- public static final int opc_tableswitch = 170;
+- public static final int opc_lookupswitch = 171;
+- public static final int opc_ireturn = 172;
+- public static final int opc_lreturn = 173;
+- public static final int opc_freturn = 174;
+- public static final int opc_dreturn = 175;
+- public static final int opc_areturn = 176;
+- public static final int opc_return = 177;
+- public static final int opc_getstatic = 178;
+- public static final int opc_putstatic = 179;
+- public static final int opc_getfield = 180;
+- public static final int opc_putfield = 181;
+- public static final int opc_invokevirtual = 182;
+- public static final int opc_invokenonvirtual = 183;
+- public static final int opc_invokespecial = 183;
+- public static final int opc_invokestatic = 184;
+- public static final int opc_invokeinterface = 185;
+-// public static final int opc_xxxunusedxxx = 186;
+- public static final int opc_new = 187;
+- public static final int opc_newarray = 188;
+- public static final int opc_anewarray = 189;
+- public static final int opc_arraylength = 190;
+- public static final int opc_athrow = 191;
+- public static final int opc_checkcast = 192;
+- public static final int opc_instanceof = 193;
+- public static final int opc_monitorenter = 194;
+- public static final int opc_monitorexit = 195;
+- public static final int opc_wide = 196;
+- public static final int opc_multianewarray = 197;
+- public static final int opc_ifnull = 198;
+- public static final int opc_ifnonnull = 199;
+- public static final int opc_goto_w = 200;
+- public static final int opc_jsr_w = 201;
+-
+- /* Pseudo-instructions */
+- public static final int opc_bytecode = 203;
+- public static final int opc_try = 204;
+- public static final int opc_endtry = 205;
+- public static final int opc_catch = 206;
+- public static final int opc_var = 207;
+- public static final int opc_endvar = 208;
+- public static final int opc_localsmap = 209;
+- public static final int opc_stackmap = 210;
+-
+- /* PicoJava prefixes */
+- public static final int opc_nonpriv = 254;
+- public static final int opc_priv = 255;
+-
+- /* Wide instructions */
+- public static final int opc_iload_w = (opc_wide << 8 ) | opc_iload;
+- public static final int opc_lload_w = (opc_wide << 8 ) | opc_lload;
+- public static final int opc_fload_w = (opc_wide << 8 ) | opc_fload;
+- public static final int opc_dload_w = (opc_wide << 8 ) | opc_dload;
+- public static final int opc_aload_w = (opc_wide << 8 ) | opc_aload;
+- public static final int opc_istore_w = (opc_wide << 8 ) | opc_istore;
+- public static final int opc_lstore_w = (opc_wide << 8 ) | opc_lstore;
+- public static final int opc_fstore_w = (opc_wide << 8 ) | opc_fstore;
+- public static final int opc_dstore_w = (opc_wide << 8 ) | opc_dstore;
+- public static final int opc_astore_w = (opc_wide << 8 ) | opc_astore;
+- public static final int opc_ret_w = (opc_wide << 8 ) | opc_ret;
+- public static final int opc_iinc_w = (opc_wide << 8 ) | opc_iinc;
+-
+- /* Opcode Names */
+- private static final String opcNamesTab[] = {
+- "nop",
+- "aconst_null",
+- "iconst_m1",
+- "iconst_0",
+- "iconst_1",
+- "iconst_2",
+- "iconst_3",
+- "iconst_4",
+- "iconst_5",
+- "lconst_0",
+- "lconst_1",
+- "fconst_0",
+- "fconst_1",
+- "fconst_2",
+- "dconst_0",
+- "dconst_1",
+- "bipush",
+- "sipush",
+- "ldc",
+- "ldc_w",
+- "ldc2_w",
+- "iload",
+- "lload",
+- "fload",
+- "dload",
+- "aload",
+- "iload_0",
+- "iload_1",
+- "iload_2",
+- "iload_3",
+- "lload_0",
+- "lload_1",
+- "lload_2",
+- "lload_3",
+- "fload_0",
+- "fload_1",
+- "fload_2",
+- "fload_3",
+- "dload_0",
+- "dload_1",
+- "dload_2",
+- "dload_3",
+- "aload_0",
+- "aload_1",
+- "aload_2",
+- "aload_3",
+- "iaload",
+- "laload",
+- "faload",
+- "daload",
+- "aaload",
+- "baload",
+- "caload",
+- "saload",
+- "istore",
+- "lstore",
+- "fstore",
+- "dstore",
+- "astore",
+- "istore_0",
+- "istore_1",
+- "istore_2",
+- "istore_3",
+- "lstore_0",
+- "lstore_1",
+- "lstore_2",
+- "lstore_3",
+- "fstore_0",
+- "fstore_1",
+- "fstore_2",
+- "fstore_3",
+- "dstore_0",
+- "dstore_1",
+- "dstore_2",
+- "dstore_3",
+- "astore_0",
+- "astore_1",
+- "astore_2",
+- "astore_3",
+- "iastore",
+- "lastore",
+- "fastore",
+- "dastore",
+- "aastore",
+- "bastore",
+- "castore",
+- "sastore",
+- "pop",
+- "pop2",
+- "dup",
+- "dup_x1",
+- "dup_x2",
+- "dup2",
+- "dup2_x1",
+- "dup2_x2",
+- "swap",
+- "iadd",
+- "ladd",
+- "fadd",
+- "dadd",
+- "isub",
+- "lsub",
+- "fsub",
+- "dsub",
+- "imul",
+- "lmul",
+- "fmul",
+- "dmul",
+- "idiv",
+- "ldiv",
+- "fdiv",
+- "ddiv",
+- "irem",
+- "lrem",
+- "frem",
+- "drem",
+- "ineg",
+- "lneg",
+- "fneg",
+- "dneg",
+- "ishl",
+- "lshl",
+- "ishr",
+- "lshr",
+- "iushr",
+- "lushr",
+- "iand",
+- "land",
+- "ior",
+- "lor",
+- "ixor",
+- "lxor",
+- "iinc",
+- "i2l",
+- "i2f",
+- "i2d",
+- "l2i",
+- "l2f",
+- "l2d",
+- "f2i",
+- "f2l",
+- "f2d",
+- "d2i",
+- "d2l",
+- "d2f",
+- "i2b",
+- "i2c",
+- "i2s",
+- "lcmp",
+- "fcmpl",
+- "fcmpg",
+- "dcmpl",
+- "dcmpg",
+- "ifeq",
+- "ifne",
+- "iflt",
+- "ifge",
+- "ifgt",
+- "ifle",
+- "if_icmpeq",
+- "if_icmpne",
+- "if_icmplt",
+- "if_icmpge",
+- "if_icmpgt",
+- "if_icmple",
+- "if_acmpeq",
+- "if_acmpne",
+- "goto",
+- "jsr",
+- "ret",
+- "tableswitch",
+- "lookupswitch",
+- "ireturn",
+- "lreturn",
+- "freturn",
+- "dreturn",
+- "areturn",
+- "return",
+- "getstatic",
+- "putstatic",
+- "getfield",
+- "putfield",
+- "invokevirtual",
+- "invokespecial", // was "invokenonvirtual",
+- "invokestatic",
+- "invokeinterface",
+- "bytecode 186", //"xxxunusedxxx",
+- "new",
+- "newarray",
+- "anewarray",
+- "arraylength",
+- "athrow",
+- "checkcast",
+- "instanceof",
+- "monitorenter",
+- "monitorexit",
+- null, // "wide",
+- "multianewarray",
+- "ifnull",
+- "ifnonnull",
+- "goto_w",
+- "jsr_w",
+- "bytecode 202", // "breakpoint",
+- "bytecode",
+- "try",
+- "endtry",
+- "catch",
+- "var",
+- "endvar",
+- "locals_map",
+- "stack_map"
+- };
+-
+- /* Opcode Lengths */
+- private static final int opcLengthsTab[] = {
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 2,
+- 3,
+- 2,
+- 3,
+- 3,
+- 2,
+- 2,
+- 2,
+- 2,
+- 2,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 2,
+- 2,
+- 2,
+- 2,
+- 2,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 3,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 2,
+- 99,
+- 99,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 1,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 3,
+- 5,
+- 0,
+- 3,
+- 2,
+- 3,
+- 1,
+- 1,
+- 3,
+- 3,
+- 1,
+- 1,
+- 0, // wide
+- 4,
+- 3,
+- 3,
+- 5,
+- 5,
+- 1,
+- 1, 0, 0, 0, 0, 0 // pseudo
+- };
+-
+- /* Type codes, used in newarray opcode */
+- public static final int T_CLASS = 0x00000002;
+- public static final int T_BOOLEAN = 0x00000004;
+- public static final int T_CHAR = 0x00000005;
+- public static final int T_FLOAT = 0x00000006;
+- public static final int T_DOUBLE = 0x00000007;
+- public static final int T_BYTE = 0x00000008;
+- public static final int T_SHORT = 0x00000009;
+- public static final int T_INT = 0x0000000a;
+- public static final int T_LONG = 0x0000000b;
+-
+- private static HashMap<String,Integer> mnemocodes = new HashMap<String,Integer>(301, 0.5f);
+- private static String opcExtNamesTab[]=new String[128];
+- private static String opcPrivExtNamesTab[]=new String[128];
+-
+- private static void defineNonPriv(int opc, String mnem) {
+- mnemocodes.put(opcExtNamesTab[opc] = mnem, opc_nonpriv * 256 + opc);
+- }
+-
+- private static void definePriv(int opc, String mnem) {
+- mnemocodes.put(opcPrivExtNamesTab[opc] = "priv_" + mnem, opc_priv * 256 + opc);
+- }
+-
+- private static void defineExt(int opc, String mnem) {
+- defineNonPriv(opc, mnem);
+- definePriv(opc, mnem);
+- }
+-
+- static {
+- for (int i = 0; i < opc_wide; i++) {
+- mnemocodes.put(opcNamesTab[i], i);
+- }
+- for (int i = opc_wide + 1; i < opcNamesTab.length; i++) {
+- mnemocodes.put(opcNamesTab[i], i);
+- }
+- mnemocodes.put("invokenonvirtual", opc_invokespecial);
+-
+- mnemocodes.put("iload_w", opc_iload_w);
+- mnemocodes.put("lload_w", opc_lload_w);
+- mnemocodes.put("fload_w", opc_fload_w);
+- mnemocodes.put("dload_w", opc_dload_w);
+- mnemocodes.put("aload_w", opc_aload_w);
+- mnemocodes.put("istore_w", opc_istore_w);
+- mnemocodes.put("lstore_w", opc_lstore_w);
+- mnemocodes.put("fstore_w", opc_fstore_w);
+- mnemocodes.put("dstore_w", opc_dstore_w);
+- mnemocodes.put("astore_w", opc_astore_w);
+- mnemocodes.put("ret_w", opc_ret_w);
+- mnemocodes.put("iinc_w", opc_iinc_w);
+-
+- mnemocodes.put("nonpriv", opc_nonpriv);
+- mnemocodes.put("priv", opc_priv);
+-
+- defineExt(0, "load_ubyte");
+- defineExt(1, "load_byte");
+- defineExt(2, "load_char");
+- defineExt(3, "load_short");
+- defineExt(4, "load_word");
+- defineExt(10, "load_char_oe");
+- defineExt(11, "load_short_oe");
+- defineExt(12, "load_word_oe");
+- defineExt(16, "ncload_ubyte");
+- defineExt(17, "ncload_byte");
+- defineExt(18, "ncload_char");
+- defineExt(19, "ncload_short");
+- defineExt(20, "ncload_word");
+- defineExt(26, "ncload_char_oe");
+- defineExt(27, "ncload_short_oe");
+- defineExt(28, "ncload_word_oe");
+- defineExt(30, "cache_flush");
+- defineExt(32, "store_byte");
+- defineExt(34, "store_short");
+- defineExt(36, "store_word");
+- defineExt(42, "store_short_oe");
+- defineExt(44, "store_word_oe");
+- defineExt(48, "ncstore_byte");
+- defineExt(50, "ncstore_short");
+- defineExt(52, "ncstore_word");
+- defineExt(58, "ncstore_short_oe");
+- defineExt(60, "ncstore_word_oe");
+- defineExt(62, "zero_line");
+- defineNonPriv(5, "ret_from_sub");
+- defineNonPriv(63, "enter_sync_method");
+- definePriv(5, "ret_from_trap");
+- definePriv(6, "read_dcache_tag");
+- definePriv(7, "read_dcache_data");
+- definePriv(14, "read_icache_tag");
+- definePriv(15, "read_icache_data");
+- definePriv(22, "powerdown");
+- definePriv(23, "read_scache_data");
+- definePriv(31, "cache_index_flush");
+- definePriv(38, "write_dcache_tag");
+- definePriv(39, "write_dcache_data");
+- definePriv(46, "write_icache_tag");
+- definePriv(47, "write_icache_data");
+- definePriv(54, "reset");
+- definePriv(55, "write_scache_data");
+- for (int i = 0; i < 32; i++) {
+- definePriv(i + 64, "read_reg_" + i);
+- }
+- for (int i = 0; i < 32; i++) {
+- definePriv(i + 96, "write_reg_" + i);
+- }
+- }
+-}
+diff -r bfd7bb421825 -r 3cbaa3d49584 src/share/classes/com/sun/tools/classfile/Opcode.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/classfile/Opcode.java Thu Oct 24 02:40:06 2013 +0100
+@@ -0,0 +1,472 @@
++/*
++ * 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 com.sun.tools.classfile;
++
++import static com.sun.tools.classfile.Instruction.Kind.*;
++import static com.sun.tools.classfile.Opcode.Set.*;
++
++/**
++ * See JVMS3, chapter 6.
++ *
++ * <p>In addition to providing all the standard opcodes defined in JVMS,
++ * this class also provides legacy support for the PicoJava extensions.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public enum Opcode {
++ NOP(0x0),
++ ACONST_NULL(0x1),
++ ICONST_M1(0x2),
++ ICONST_0(0x3),
++ ICONST_1(0x4),
++ ICONST_2(0x5),
++ ICONST_3(0x6),
++ ICONST_4(0x7),
++ ICONST_5(0x8),
++ LCONST_0(0x9),
++ LCONST_1(0xa),
++ FCONST_0(0xb),
++ FCONST_1(0xc),
++ FCONST_2(0xd),
++ DCONST_0(0xe),
++ DCONST_1(0xf),
++ BIPUSH(0x10, BYTE),
++ SIPUSH(0x11, SHORT),
++ LDC(0x12, CPREF),
++ LDC_W(0x13, CPREF_W),
++ LDC2_W(0x14, CPREF_W),
++ ILOAD(0x15, LOCAL),
++ LLOAD(0x16, LOCAL),
++ FLOAD(0x17, LOCAL),
++ DLOAD(0x18, LOCAL),
++ ALOAD(0x19, LOCAL),
++ ILOAD_0(0x1a),
++ ILOAD_1(0x1b),
++ ILOAD_2(0x1c),
++ ILOAD_3(0x1d),
++ LLOAD_0(0x1e),
++ LLOAD_1(0x1f),
++ LLOAD_2(0x20),
++ LLOAD_3(0x21),
++ FLOAD_0(0x22),
++ FLOAD_1(0x23),
++ FLOAD_2(0x24),
++ FLOAD_3(0x25),
++ DLOAD_0(0x26),
++ DLOAD_1(0x27),
++ DLOAD_2(0x28),
++ DLOAD_3(0x29),
++ ALOAD_0(0x2a),
++ ALOAD_1(0x2b),
++ ALOAD_2(0x2c),
++ ALOAD_3(0x2d),
++ IALOAD(0x2e),
++ LALOAD(0x2f),
++ FALOAD(0x30),
++ DALOAD(0x31),
++ AALOAD(0x32),
++ BALOAD(0x33),
++ CALOAD(0x34),
++ SALOAD(0x35),
++ ISTORE(0x36, LOCAL),
++ LSTORE(0x37, LOCAL),
++ FSTORE(0x38, LOCAL),
++ DSTORE(0x39, LOCAL),
++ ASTORE(0x3a, LOCAL),
++ ISTORE_0(0x3b),
++ ISTORE_1(0x3c),
++ ISTORE_2(0x3d),
++ ISTORE_3(0x3e),
++ LSTORE_0(0x3f),
++ LSTORE_1(0x40),
++ LSTORE_2(0x41),
++ LSTORE_3(0x42),
++ FSTORE_0(0x43),
++ FSTORE_1(0x44),
++ FSTORE_2(0x45),
++ FSTORE_3(0x46),
++ DSTORE_0(0x47),
++ DSTORE_1(0x48),
++ DSTORE_2(0x49),
++ DSTORE_3(0x4a),
++ ASTORE_0(0x4b),
++ ASTORE_1(0x4c),
++ ASTORE_2(0x4d),
++ ASTORE_3(0x4e),
++ IASTORE(0x4f),
++ LASTORE(0x50),
++ FASTORE(0x51),
++ DASTORE(0x52),
++ AASTORE(0x53),
++ BASTORE(0x54),
++ CASTORE(0x55),
++ SASTORE(0x56),
++ POP(0x57),
++ POP2(0x58),
++ DUP(0x59),
++ DUP_X1(0x5a),
++ DUP_X2(0x5b),
++ DUP2(0x5c),
++ DUP2_X1(0x5d),
++ DUP2_X2(0x5e),
++ SWAP(0x5f),
++ IADD(0x60),
++ LADD(0x61),
++ FADD(0x62),
++ DADD(0x63),
++ ISUB(0x64),
++ LSUB(0x65),
++ FSUB(0x66),
++ DSUB(0x67),
++ IMUL(0x68),
++ LMUL(0x69),
++ FMUL(0x6a),
++ DMUL(0x6b),
++ IDIV(0x6c),
++ LDIV(0x6d),
++ FDIV(0x6e),
++ DDIV(0x6f),
++ IREM(0x70),
++ LREM(0x71),
++ FREM(0x72),
++ DREM(0x73),
++ INEG(0x74),
++ LNEG(0x75),
++ FNEG(0x76),
++ DNEG(0x77),
++ ISHL(0x78),
++ LSHL(0x79),
++ ISHR(0x7a),
++ LSHR(0x7b),
++ IUSHR(0x7c),
++ LUSHR(0x7d),
++ IAND(0x7e),
++ LAND(0x7f),
++ IOR(0x80),
++ LOR(0x81),
++ IXOR(0x82),
++ LXOR(0x83),
++ IINC(0x84, LOCAL_BYTE),
++ I2L(0x85),
++ I2F(0x86),
++ I2D(0x87),
++ L2I(0x88),
++ L2F(0x89),
++ L2D(0x8a),
++ F2I(0x8b),
++ F2L(0x8c),
++ F2D(0x8d),
++ D2I(0x8e),
++ D2L(0x8f),
++ D2F(0x90),
++ I2B(0x91),
++ I2C(0x92),
++ I2S(0x93),
++ LCMP(0x94),
++ FCMPL(0x95),
++ FCMPG(0x96),
++ DCMPL(0x97),
++ DCMPG(0x98),
++ IFEQ(0x99, BRANCH),
++ IFNE(0x9a, BRANCH),
++ IFLT(0x9b, BRANCH),
++ IFGE(0x9c, BRANCH),
++ IFGT(0x9d, BRANCH),
++ IFLE(0x9e, BRANCH),
++ IF_ICMPEQ(0x9f, BRANCH),
++ IF_ICMPNE(0xa0, BRANCH),
++ IF_ICMPLT(0xa1, BRANCH),
++ IF_ICMPGE(0xa2, BRANCH),
++ IF_ICMPGT(0xa3, BRANCH),
++ IF_ICMPLE(0xa4, BRANCH),
++ IF_ACMPEQ(0xa5, BRANCH),
++ IF_ACMPNE(0xa6, BRANCH),
++ GOTO(0xa7, BRANCH),
++ JSR(0xa8, BRANCH),
++ RET(0xa9, LOCAL),
++ TABLESWITCH(0xaa, DYNAMIC),
++ LOOKUPSWITCH(0xab, DYNAMIC),
++ IRETURN(0xac),
++ LRETURN(0xad),
++ FRETURN(0xae),
++ DRETURN(0xaf),
++ ARETURN(0xb0),
++ RETURN(0xb1),
++ GETSTATIC(0xb2, CPREF_W),
++ PUTSTATIC(0xb3, CPREF_W),
++ GETFIELD(0xb4, CPREF_W),
++ PUTFIELD(0xb5, CPREF_W),
++ INVOKEVIRTUAL(0xb6, CPREF_W),
++ INVOKESPECIAL(0xb7, CPREF_W),
++ INVOKESTATIC(0xb8, CPREF_W),
++ INVOKEINTERFACE(0xb9, CPREF_W_UBYTE_ZERO),
++ // unused 0xba
++ NEW(0xbb, CPREF_W),
++ NEWARRAY(0xbc, ATYPE),
++ ANEWARRAY(0xbd, CPREF_W),
++ ARRAYLENGTH(0xbe),
++ ATHROW(0xbf),
++ CHECKCAST(0xc0, CPREF_W),
++ INSTANCEOF(0xc1, CPREF_W),
++ MONITORENTER(0xc2),
++ MONITOREXIT(0xc3),
++ // wide 0xc4
++ MULTIANEWARRAY(0xc5, CPREF_W_UBYTE),
++ IFNULL(0xc6, BRANCH),
++ IFNONNULL(0xc7, BRANCH),
++ GOTO_W(0xc8, BRANCH_W),
++ JSR_W(0xc9, BRANCH_W),
++ // impdep 0xfe: PicoJava nonpriv
++ // impdep 0xff: Picojava priv
++
++ // wide opcodes
++ ILOAD_W(0xc415, WIDE_CPREF_W),
++ LLOAD_W(0xc416, WIDE_CPREF_W),
++ FLOAD_W(0xc417, WIDE_CPREF_W),
++ DLOAD_W(0xc418, WIDE_CPREF_W),
++ ALOAD_W(0xc419, WIDE_CPREF_W),
++ ISTORE_W(0xc436, WIDE_CPREF_W),
++ LSTORE_W(0xc437, WIDE_CPREF_W),
++ FSTORE_W(0xc438, WIDE_CPREF_W),
++ DSTORE_W(0xc439, WIDE_CPREF_W),
++ ASTORE_W(0xc43a, WIDE_CPREF_W),
++ IINC_W(0xc484, WIDE_CPREF_W_SHORT),
++ RET_W(0xc4a9, WIDE_CPREF_W),
++
++ // PicoJava nonpriv instructions
++ LOAD_UBYTE(PICOJAVA, 0xfe00),
++ LOAD_BYTE(PICOJAVA, 0xfe01),
++ LOAD_CHAR(PICOJAVA, 0xfe02),
++ LOAD_SHORT(PICOJAVA, 0xfe03),
++ LOAD_WORD(PICOJAVA, 0xfe04),
++ RET_FROM_SUB(PICOJAVA, 0xfe05),
++ LOAD_CHAR_OE(PICOJAVA, 0xfe0a),
++ LOAD_SHORT_OE(PICOJAVA, 0xfe0b),
++ LOAD_WORD_OE(PICOJAVA, 0xfe0c),
++ NCLOAD_UBYTE(PICOJAVA, 0xfe10),
++ NCLOAD_BYTE(PICOJAVA, 0xfe11),
++ NCLOAD_CHAR(PICOJAVA, 0xfe12),
++ NCLOAD_SHORT(PICOJAVA, 0xfe13),
++ NCLOAD_WORD(PICOJAVA, 0xfe14),
++ NCLOAD_CHAR_OE(PICOJAVA, 0xfe1a),
++ NCLOAD_SHORT_OE(PICOJAVA, 0xfe1b),
++ NCLOAD_WORD_OE(PICOJAVA, 0xfe1c),
++ CACHE_FLUSH(PICOJAVA, 0xfe1e),
++ STORE_BYTE(PICOJAVA, 0xfe20),
++ STORE_SHORT(PICOJAVA, 0xfe22),
++ STORE_WORD(PICOJAVA, 0xfe24),
++ STORE_SHORT_OE(PICOJAVA, 0xfe2a),
++ STORE_WORD_OE(PICOJAVA, 0xfe2c),
++ NCSTORE_BYTE(PICOJAVA, 0xfe30),
++ NCSTORE_SHORT(PICOJAVA, 0xfe32),
++ NCSTORE_WORD(PICOJAVA, 0xfe34),
++ NCSTORE_SHORT_OE(PICOJAVA, 0xfe3a),
++ NCSTORE_WORD_OE(PICOJAVA, 0xfe3c),
++ ZERO_LINE(PICOJAVA, 0xfe3e),
++ ENTER_SYNC_METHOD(PICOJAVA, 0xfe3f),
++
++ // PicoJava priv instructions
++ PRIV_LOAD_UBYTE(PICOJAVA, 0xff00),
++ PRIV_LOAD_BYTE(PICOJAVA, 0xff01),
++ PRIV_LOAD_CHAR(PICOJAVA, 0xff02),
++ PRIV_LOAD_SHORT(PICOJAVA, 0xff03),
++ PRIV_LOAD_WORD(PICOJAVA, 0xff04),
++ PRIV_RET_FROM_TRAP(PICOJAVA, 0xff05),
++ PRIV_READ_DCACHE_TAG(PICOJAVA, 0xff06),
++ PRIV_READ_DCACHE_DATA(PICOJAVA, 0xff07),
++ PRIV_LOAD_CHAR_OE(PICOJAVA, 0xff0a),
++ PRIV_LOAD_SHORT_OE(PICOJAVA, 0xff0b),
++ PRIV_LOAD_WORD_OE(PICOJAVA, 0xff0c),
++ PRIV_READ_ICACHE_TAG(PICOJAVA, 0xff0e),
++ PRIV_READ_ICACHE_DATA(PICOJAVA, 0xff0f),
++ PRIV_NCLOAD_UBYTE(PICOJAVA, 0xff10),
++ PRIV_NCLOAD_BYTE(PICOJAVA, 0xff11),
++ PRIV_NCLOAD_CHAR(PICOJAVA, 0xff12),
++ PRIV_NCLOAD_SHORT(PICOJAVA, 0xff13),
++ PRIV_NCLOAD_WORD(PICOJAVA, 0xff14),
++ PRIV_POWERDOWN(PICOJAVA, 0xff16),
++ PRIV_READ_SCACHE_DATA(PICOJAVA, 0xff17),
++ PRIV_NCLOAD_CHAR_OE(PICOJAVA, 0xff1a),
++ PRIV_NCLOAD_SHORT_OE(PICOJAVA, 0xff1b),
++ PRIV_NCLOAD_WORD_OE(PICOJAVA, 0xff1c),
++ PRIV_CACHE_FLUSH(PICOJAVA, 0xff1e),
++ PRIV_CACHE_INDEX_FLUSH(PICOJAVA, 0xff1f),
++ PRIV_STORE_BYTE(PICOJAVA, 0xff20),
++ PRIV_STORE_SHORT(PICOJAVA, 0xff22),
++ PRIV_STORE_WORD(PICOJAVA, 0xff24),
++ PRIV_WRITE_DCACHE_TAG(PICOJAVA, 0xff26),
++ PRIV_WRITE_DCACHE_DATA(PICOJAVA, 0xff27),
++ PRIV_STORE_SHORT_OE(PICOJAVA, 0xff2a),
++ PRIV_STORE_WORD_OE(PICOJAVA, 0xff2c),
++ PRIV_WRITE_ICACHE_TAG(PICOJAVA, 0xff2e),
++ PRIV_WRITE_ICACHE_DATA(PICOJAVA, 0xff2f),
++ PRIV_NCSTORE_BYTE(PICOJAVA, 0xff30),
++ PRIV_NCSTORE_SHORT(PICOJAVA, 0xff32),
++ PRIV_NCSTORE_WORD(PICOJAVA, 0xff34),
++ PRIV_RESET(PICOJAVA, 0xff36),
++ PRIV_WRITE_SCACHE_DATA(PICOJAVA, 0xff37),
++ PRIV_NCSTORE_SHORT_OE(PICOJAVA, 0xff3a),
++ PRIV_NCSTORE_WORD_OE(PICOJAVA, 0xff3c),
++ PRIV_ZERO_LINE(PICOJAVA, 0xff3e),
++ PRIV_READ_REG_0(PICOJAVA, 0xff40),
++ PRIV_READ_REG_1(PICOJAVA, 0xff41),
++ PRIV_READ_REG_2(PICOJAVA, 0xff42),
++ PRIV_READ_REG_3(PICOJAVA, 0xff43),
++ PRIV_READ_REG_4(PICOJAVA, 0xff44),
++ PRIV_READ_REG_5(PICOJAVA, 0xff45),
++ PRIV_READ_REG_6(PICOJAVA, 0xff46),
++ PRIV_READ_REG_7(PICOJAVA, 0xff47),
++ PRIV_READ_REG_8(PICOJAVA, 0xff48),
++ PRIV_READ_REG_9(PICOJAVA, 0xff49),
++ PRIV_READ_REG_10(PICOJAVA, 0xff4a),
++ PRIV_READ_REG_11(PICOJAVA, 0xff4b),
++ PRIV_READ_REG_12(PICOJAVA, 0xff4c),
++ PRIV_READ_REG_13(PICOJAVA, 0xff4d),
++ PRIV_READ_REG_14(PICOJAVA, 0xff4e),
++ PRIV_READ_REG_15(PICOJAVA, 0xff4f),
++ PRIV_READ_REG_16(PICOJAVA, 0xff50),
++ PRIV_READ_REG_17(PICOJAVA, 0xff51),
++ PRIV_READ_REG_18(PICOJAVA, 0xff52),
++ PRIV_READ_REG_19(PICOJAVA, 0xff53),
++ PRIV_READ_REG_20(PICOJAVA, 0xff54),
++ PRIV_READ_REG_21(PICOJAVA, 0xff55),
++ PRIV_READ_REG_22(PICOJAVA, 0xff56),
++ PRIV_READ_REG_23(PICOJAVA, 0xff57),
++ PRIV_READ_REG_24(PICOJAVA, 0xff58),
++ PRIV_READ_REG_25(PICOJAVA, 0xff59),
++ PRIV_READ_REG_26(PICOJAVA, 0xff5a),
++ PRIV_READ_REG_27(PICOJAVA, 0xff5b),
++ PRIV_READ_REG_28(PICOJAVA, 0xff5c),
++ PRIV_READ_REG_29(PICOJAVA, 0xff5d),
++ PRIV_READ_REG_30(PICOJAVA, 0xff5e),
++ PRIV_READ_REG_31(PICOJAVA, 0xff5f),
++ PRIV_WRITE_REG_0(PICOJAVA, 0xff60),
++ PRIV_WRITE_REG_1(PICOJAVA, 0xff61),
++ PRIV_WRITE_REG_2(PICOJAVA, 0xff62),
++ PRIV_WRITE_REG_3(PICOJAVA, 0xff63),
++ PRIV_WRITE_REG_4(PICOJAVA, 0xff64),
++ PRIV_WRITE_REG_5(PICOJAVA, 0xff65),
++ PRIV_WRITE_REG_6(PICOJAVA, 0xff66),
++ PRIV_WRITE_REG_7(PICOJAVA, 0xff67),
++ PRIV_WRITE_REG_8(PICOJAVA, 0xff68),
++ PRIV_WRITE_REG_9(PICOJAVA, 0xff69),
++ PRIV_WRITE_REG_10(PICOJAVA, 0xff6a),
++ PRIV_WRITE_REG_11(PICOJAVA, 0xff6b),
++ PRIV_WRITE_REG_12(PICOJAVA, 0xff6c),
++ PRIV_WRITE_REG_13(PICOJAVA, 0xff6d),
++ PRIV_WRITE_REG_14(PICOJAVA, 0xff6e),
++ PRIV_WRITE_REG_15(PICOJAVA, 0xff6f),
++ PRIV_WRITE_REG_16(PICOJAVA, 0xff70),
++ PRIV_WRITE_REG_17(PICOJAVA, 0xff71),
++ PRIV_WRITE_REG_18(PICOJAVA, 0xff72),
++ PRIV_WRITE_REG_19(PICOJAVA, 0xff73),
++ PRIV_WRITE_REG_20(PICOJAVA, 0xff74),
++ PRIV_WRITE_REG_21(PICOJAVA, 0xff75),
++ PRIV_WRITE_REG_22(PICOJAVA, 0xff76),
++ PRIV_WRITE_REG_23(PICOJAVA, 0xff77),
++ PRIV_WRITE_REG_24(PICOJAVA, 0xff78),
++ PRIV_WRITE_REG_25(PICOJAVA, 0xff79),
++ PRIV_WRITE_REG_26(PICOJAVA, 0xff7a),
++ PRIV_WRITE_REG_27(PICOJAVA, 0xff7b),
++ PRIV_WRITE_REG_28(PICOJAVA, 0xff7c),
++ PRIV_WRITE_REG_29(PICOJAVA, 0xff7d),
++ PRIV_WRITE_REG_30(PICOJAVA, 0xff7e),
++ PRIV_WRITE_REG_31(PICOJAVA, 0xff7f);
++
++ Opcode(int opcode) {
++ this(STANDARD, opcode, NO_OPERANDS);
++ }
++
++ Opcode(int opcode, Instruction.Kind kind) {
++ this(STANDARD, opcode, kind);
++ }
++
++ Opcode(Set set, int opcode) {
++ this(set, opcode, (set == STANDARD ? NO_OPERANDS : WIDE_NO_OPERANDS));
++ }
++
++ Opcode(Set set, int opcode, Instruction.Kind kind) {
++ this.set = set;
++ this.opcode = opcode;
++ this.kind = kind;
++ }
++
++ public final Set set;
++ public final int opcode;
++ public final Instruction.Kind kind;
++
++ /** Get the Opcode for a simple standard 1-byte opcode. */
++ public static Opcode get(int opcode) {
++ return stdOpcodes[opcode];
++ }
++
++ /** Get the Opcode for 1- or 2-byte opcode. */
++ public static Opcode get(int opcodePrefix, int opcode) {
++ Opcode[] block = getOpcodeBlock(opcodePrefix);
++ return (block == null ? null : block[opcode]);
++ }
++
++ private static Opcode[] getOpcodeBlock(int opcodePrefix) {
++ switch (opcodePrefix) {
++ case 0:
++ return stdOpcodes;
++ case WIDE:
++ return wideOpcodes;
++ case NONPRIV:
++ return nonPrivOpcodes;
++ case PRIV:
++ return privOpcodes;
++ default:
++ return null;
++ }
++
++ }
++
++ private static Opcode[] stdOpcodes = new Opcode[256];
++ private static Opcode[] wideOpcodes = new Opcode[256];
++ private static Opcode[] nonPrivOpcodes = new Opcode[256];
++ private static Opcode[] privOpcodes = new Opcode[256];
++ static {
++ for (Opcode o: values())
++ getOpcodeBlock(o.opcode >> 8)[o.opcode & 0xff] = o;
++ }
++
++ /** The byte prefix for the wide instructions. */
++ public static final int WIDE = 0xc4;
++ /** The byte prefix for the PicoJava nonpriv instructions. */
++ public static final int NONPRIV = 0xfe;
++ /** The byte prefix for the PicoJava priv instructions. */
++ public static final int PRIV = 0xff;
++
++ public enum Set {
++ /** Standard opcodes. */
++ STANDARD,
++ /** Legacy support for PicoJava opcodes. */
++ PICOJAVA };
++}
+diff -r bfd7bb421825 -r 3cbaa3d49584 src/share/classes/com/sun/tools/javap/CodeWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Tue Oct 22 01:03:49 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Thu Oct 24 02:40:06 2013 +0100
+@@ -30,9 +30,12 @@
+ import com.sun.tools.classfile.ConstantPool;
+ import com.sun.tools.classfile.ConstantPoolException;
+ import com.sun.tools.classfile.DescriptorException;
++import com.sun.tools.classfile.Instruction;
++import com.sun.tools.classfile.Instruction.TypeKind;
+ import com.sun.tools.classfile.Method;
++import com.sun.tools.classfile.Opcode;
+
+-import static com.sun.tools.classfile.OpCodes.*;
++//import static com.sun.tools.classfile.OpCodes.*;
+
+ /*
+ * Write the contents of a Code attribute.
+@@ -87,218 +90,92 @@
+ }
+
+ public void writeInstrs(Code_attribute attr) {
+- try {
+- for (int pc = 0; pc < attr.code_length;) {
+- print(" " + pc + ":\t");
+- pc += writeInstr(attr, pc);
+- println();
++ for (Instruction instr: attr.getInstructions()) {
++ try {
++ writeInstr(instr);
++ } catch (ArrayIndexOutOfBoundsException e) {
++ println(report("error at or after byte " + instr.getPC()));
++ break;
+ }
+- } catch (Code_attribute.InvalidIndex e) {
+- println(report(e));
+ }
+ }
+
+- public int writeInstr(Code_attribute attr, int pc)
+- throws Code_attribute.InvalidIndex {
+- String lP = "";
+- int opcode = attr.getUnsignedByte(pc);
+- int opcode2;
+- String mnem;
+- switch (opcode) {
+- case opc_nonpriv:
+- case opc_priv: {
+- opcode2 = attr.getUnsignedByte(pc + 1);
+- mnem = opcName((opcode << 8) + opcode2);
+- if (mnem == null) {
+- mnem = opcName(opcode) + " " + opcode2;
+- }
+- print(mnem);
+- return 2;
++ public void writeInstr(Instruction instr) {
++ print(" " + instr.getPC() + ":\t");
++ print(instr.getMnemonic());
++ instr.accept(instructionPrinter, null);
++ println();
++ }
++ // where
++ Instruction.KindVisitor<Void,Void> instructionPrinter =
++ new Instruction.KindVisitor<Void,Void>() {
++
++ public Void visitNoOperands(Instruction instr, Void p) {
++ return null;
++ }
++
++ public Void visitArrayType(Instruction instr, TypeKind kind, Void p) {
++ print(" " + kind.name);
++ return null;
++ }
++
++ public Void visitBranch(Instruction instr, int offset, Void p) {
++ print("\t" + (instr.getPC() + offset));
++ return null;
++ }
++
++ public Void visitConstantPoolRef(Instruction instr, int index, Void p) {
++ print("\t#" + index + "; //");
++ printConstant(index);
++ return null;
++ }
++
++ public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Void p) {
++ print("\t#" + index + ", " + value + "; //");
++ printConstant(index);
++ return null;
++ }
++
++ public Void visitLocal(Instruction instr, int index, Void p) {
++ print("\t" + index);
++ return null;
++ }
++
++ public Void visitLocalAndValue(Instruction instr, int index, int value, Void p) {
++ print("\t" + index + ", " + value);
++ return null;
++ }
++
++ public Void visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets) {
++ int pc = instr.getPC();
++ print("{ //" + npairs);
++ for (int i = 0; i < npairs; i++) {
++ print("\n\t\t" + matches[i] + ": " + (pc + offsets[i]) + ";");
+ }
+- case opc_wide: {
+- opcode2 = attr.getUnsignedByte(pc + 1);
+- mnem = opcName((opcode << 8) + opcode2);
+- if (mnem == null) {
+- print("bytecode " + opcode);
+- return 1;
+- }
+- print(mnem + " " + attr.getUnsignedShort(pc + 2));
+- if (opcode2 == opc_iinc) {
+- print(", " + attr.getShort(pc + 4));
+- return 6;
+- }
+- return 4;
++ print("\n\t\tdefault: " + (pc + default_) + " }");
++ return null;
++ }
++
++ public Void visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets) {
++ int pc = instr.getPC();
++ print("{ //" + low + " to " + high);
++ for (int i = 0; i < offsets.length; i++) {
++ print("\n\t\t" + (low + i) + ": " + (pc + offsets[i]) + ";");
+ }
++ print("\n\t\tdefault: " + (pc + default_) + " }");
++ return null;
+ }
+- mnem = opcName(opcode);
+- if (mnem == null) {
+- print("bytecode " + opcode);
+- return 1;
++
++ public Void visitValue(Instruction instr, int value, Void p) {
++ print("\t" + value);
++ return null;
+ }
+- if (opcode > opc_jsr_w) {
+- print("bytecode " + opcode);
+- return 1;
++
++ public Void visitUnknown(Instruction instr, Void p) {
++ return null;
+ }
+- print(opcName(opcode));
+- switch (opcode) {
+- case opc_aload:
+- case opc_astore:
+- case opc_fload:
+- case opc_fstore:
+- case opc_iload:
+- case opc_istore:
+- case opc_lload:
+- case opc_lstore:
+- case opc_dload:
+- case opc_dstore:
+- case opc_ret:
+- print("\t" + attr.getUnsignedByte(pc + 1));
+- return 2;
+- case opc_iinc:
+- print("\t" + attr.getUnsignedByte(pc + 1) + ", " + attr.getByte(pc + 2));
+- return 3;
+- case opc_tableswitch:
+- {
+- int tb = align(pc + 1);
+- int default_skip = attr.getInt(tb);
+- int low = attr.getInt(tb + 4);
+- int high = attr.getInt(tb + 8);
+- int count = high - low;
+- print("{ //" + low + " to " + high);
+- for (int i = 0; i <= count; i++) {
+- print("\n\t\t" + (i + low) + ": " + lP + (pc + attr.getInt(tb + 12 + 4 * i)) + ";");
+- }
+- print("\n\t\tdefault: " + lP + (default_skip + pc) + " }");
+- return tb - pc + 16 + count * 4;
+- }
+- case opc_lookupswitch:
+- {
+- int tb = align(pc + 1);
+- int default_skip = attr.getInt(tb);
+- int npairs = attr.getInt(tb + 4);
+- print("{ //" + npairs);
+- for (int i = 1; i <= npairs; i++) {
+- print("\n\t\t" + attr.getInt(tb + i * 8) + ": " + lP + (pc + attr.getInt(tb + 4 + i * 8)) + ";");
+- }
+- print("\n\t\tdefault: " + lP + (default_skip + pc) + " }");
+- return tb - pc + (npairs + 1) * 8;
+- }
+- case opc_newarray:
+- int type = attr.getUnsignedByte(pc + 1);
+- switch (type) {
+- case T_BOOLEAN:
+- print(" boolean");
+- break;
+- case T_BYTE:
+- print(" byte");
+- break;
+- case T_CHAR:
+- print(" char");
+- break;
+- case T_SHORT:
+- print(" short");
+- break;
+- case T_INT:
+- print(" int");
+- break;
+- case T_LONG:
+- print(" long");
+- break;
+- case T_FLOAT:
+- print(" float");
+- break;
+- case T_DOUBLE:
+- print(" double");
+- break;
+- case T_CLASS:
+- print(" class");
+- break;
+- default:
+- print(" BOGUS TYPE:" + type);
+- }
+- return 2;
+- case opc_anewarray:
+- {
+- int index = attr.getUnsignedShort(pc + 1);
+- print("\t#" + index + "; //");
+- printConstant(index);
+- return 3;
+- }
+- case opc_sipush:
+- print("\t" + attr.getShort(pc + 1));
+- return 3;
+- case opc_bipush:
+- print("\t" + attr.getByte(pc + 1));
+- return 2;
+- case opc_ldc:
+- {
+- int index = attr.getUnsignedByte(pc + 1);
+- print("\t#" + index + "; //");
+- printConstant(index);
+- return 2;
+- }
+- case opc_ldc_w:
+- case opc_ldc2_w:
+- case opc_instanceof:
+- case opc_checkcast:
+- case opc_new:
+- case opc_putstatic:
+- case opc_getstatic:
+- case opc_putfield:
+- case opc_getfield:
+- case opc_invokevirtual:
+- case opc_invokespecial:
+- case opc_invokestatic:
+- {
+- int index = attr.getUnsignedShort(pc + 1);
+- print("\t#" + index + "; //");
+- printConstant(index);
+- return 3;
+- }
+- case opc_invokeinterface:
+- {
+- int index = attr.getUnsignedShort(pc + 1);
+- int nargs = attr.getUnsignedByte(pc + 3);
+- print("\t#" + index + ", " + nargs + "; //");
+- printConstant(index);
+- return 5;
+- }
+- case opc_multianewarray:
+- {
+- int index = attr.getUnsignedShort(pc + 1);
+- int dimensions = attr.getUnsignedByte(pc + 3);
+- print("\t#" + index + ", " + dimensions + "; //");
+- printConstant(index);
+- return 4;
+- }
+- case opc_jsr:
+- case opc_goto:
+- case opc_ifeq:
+- case opc_ifge:
+- case opc_ifgt:
+- case opc_ifle:
+- case opc_iflt:
+- case opc_ifne:
+- case opc_if_icmpeq:
+- case opc_if_icmpne:
+- case opc_if_icmpge:
+- case opc_if_icmpgt:
+- case opc_if_icmple:
+- case opc_if_icmplt:
+- case opc_if_acmpeq:
+- case opc_if_acmpne:
+- case opc_ifnull:
+- case opc_ifnonnull:
+- print("\t" + lP + (pc + attr.getShort(pc + 1)));
+- return 3;
+- case opc_jsr_w:
+- case opc_goto_w:
+- print("\t" + lP + (pc + attr.getInt(pc + 1)));
+- return 5;
+- default:
+- return 1;
+- }
+- }
++ };
++
+
+ public void writeExceptionTable(Code_attribute attr) {
+ if (attr.exception_table_langth > 0) {
diff --git a/java/openjdk6/files/icedtea/openjdk/6824493-experimental.patch b/java/openjdk6/files/icedtea/openjdk/6824493-experimental.patch
new file mode 100644
index 000000000000..2e415affb7e1
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6824493-experimental.patch
@@ -0,0 +1,1304 @@
+# HG changeset patch
+# User jjg
+# Date 1242759054 25200
+# Tue May 19 11:50:54 2009 -0700
+# Node ID 4b55db11179d066331b829ca5c4722c33287deea
+# Parent 8f5d8429b3f18ee4c9820ac1fb597f63c55911f3
+6824493: experimental support for additional info for instructions
+Reviewed-by: mcimadamore
+
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java
+--- langtools/src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java Tue Jul 08 18:06:19 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java Tue May 19 11:50:54 2009 -0700
+@@ -106,6 +106,8 @@
+ return 1;
+ }
+
++ public abstract int getOffsetDelta();
++
+ public abstract <R,D> R accept(Visitor<R,D> visitor, D data);
+
+ public final int frame_type;
+@@ -129,6 +131,10 @@
+ public <R, D> R accept(Visitor<R, D> visitor, D data) {
+ return visitor.visit_same_frame(this, data);
+ }
++
++ public int getOffsetDelta() {
++ return frame_type;
++ }
+ }
+
+ public static class same_locals_1_stack_item_frame extends stack_map_frame {
+@@ -148,6 +154,10 @@
+ return visitor.visit_same_locals_1_stack_item_frame(this, data);
+ }
+
++ public int getOffsetDelta() {
++ return frame_type - 64;
++ }
++
+ public final verification_type_info[] stack;
+ }
+
+@@ -169,6 +179,10 @@
+ return visitor.visit_same_locals_1_stack_item_frame_extended(this, data);
+ }
+
++ public int getOffsetDelta() {
++ return offset_delta;
++ }
++
+ public final int offset_delta;
+ public final verification_type_info[] stack;
+ }
+@@ -188,6 +202,10 @@
+ return visitor.visit_chop_frame(this, data);
+ }
+
++ public int getOffsetDelta() {
++ return offset_delta;
++ }
++
+ public final int offset_delta;
+ }
+
+@@ -206,6 +224,10 @@
+ return visitor.visit_same_frame_extended(this, data);
+ }
+
++ public int getOffsetDelta() {
++ return offset_delta;
++ }
++
+ public final int offset_delta;
+ }
+
+@@ -231,6 +253,10 @@
+ return visitor.visit_append_frame(this, data);
+ }
+
++ public int getOffsetDelta() {
++ return offset_delta;
++ }
++
+ public final int offset_delta;
+ public final verification_type_info[] locals;
+ }
+@@ -265,6 +291,10 @@
+ return visitor.visit_full_frame(this, data);
+ }
+
++ public int getOffsetDelta() {
++ return offset_delta;
++ }
++
+ public final int offset_delta;
+ public final int number_of_locals;
+ public final verification_type_info[] locals;
+@@ -307,7 +337,7 @@
+ }
+ }
+
+- verification_type_info(int tag) {
++ protected verification_type_info(int tag) {
+ this.tag = tag;
+ }
+
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/BasicWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/BasicWriter.java Tue Jul 08 18:06:19 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/BasicWriter.java Tue May 19 11:50:54 2009 -0700
+@@ -44,6 +44,9 @@
+ protected BasicWriter(Context context) {
+ lineWriter = LineWriter.instance(context);
+ out = context.get(PrintWriter.class);
++ messages = context.get(Messages.class);
++ if (messages == null)
++ throw new AssertionError();
+ }
+
+ protected void print(String s) {
+@@ -100,8 +103,26 @@
+ return "???";
+ }
+
++ protected String space(int w) {
++ if (w < spaces.length && spaces[w] != null)
++ return spaces[w];
++
++ StringBuilder sb = new StringBuilder();
++ for (int i = 0; i < w; i++)
++ sb.append(" ");
++
++ String s = sb.toString();
++ if (w < spaces.length)
++ spaces[w] = s;
++
++ return s;
++ }
++
++ private String[] spaces = new String[80];
++
+ private LineWriter lineWriter;
+ private PrintWriter out;
++ protected Messages messages;
+
+ private static class LineWriter {
+ static LineWriter instance(Context context) {
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/ClassWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue Jul 08 18:06:19 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue May 19 11:50:54 2009 -0700
+@@ -26,7 +26,9 @@
+ package com.sun.tools.javap;
+
+ import java.net.URI;
++import java.text.DateFormat;
+ import java.util.Collection;
++import java.util.Date;
+ import java.util.List;
+
+ import com.sun.tools.classfile.AccessFlags;
+@@ -47,8 +49,6 @@
+ import com.sun.tools.classfile.SourceFile_attribute;
+ import com.sun.tools.classfile.Type;
+
+-import java.text.DateFormat;
+-import java.util.Date;
+ import static com.sun.tools.classfile.AccessFlags.*;
+
+ /*
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/CodeWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Tue Jul 08 18:06:19 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Tue May 19 11:50:54 2009 -0700
+@@ -25,6 +25,9 @@
+
+ package com.sun.tools.javap;
+
++import java.util.ArrayList;
++import java.util.List;
++
+ import com.sun.tools.classfile.AccessFlags;
+ import com.sun.tools.classfile.Code_attribute;
+ import com.sun.tools.classfile.ConstantPool;
+@@ -33,9 +36,6 @@
+ import com.sun.tools.classfile.Instruction;
+ import com.sun.tools.classfile.Instruction.TypeKind;
+ import com.sun.tools.classfile.Method;
+-import com.sun.tools.classfile.Opcode;
+-
+-//import static com.sun.tools.classfile.OpCodes.*;
+
+ /*
+ * Write the contents of a Code attribute.
+@@ -59,6 +59,12 @@
+ attrWriter = AttributeWriter.instance(context);
+ classWriter = ClassWriter.instance(context);
+ constantWriter = ConstantWriter.instance(context);
++ sourceWriter = SourceWriter.instance(context);
++ tryBlockWriter = TryBlockWriter.instance(context);
++ stackMapWriter = StackMapWriter.instance(context);
++ localVariableTableWriter = LocalVariableTableWriter.instance(context);
++ localVariableTypeTableWriter = LocalVariableTypeTableWriter.instance(context);
++ options = Options.instance(context);
+ }
+
+ void write(Code_attribute attr, ConstantPool constant_pool) {
+@@ -92,14 +98,21 @@
+ }
+
+ public void writeInstrs(Code_attribute attr) {
++ List<InstructionDetailWriter> detailWriters = getDetailWriters(attr);
++
+ for (Instruction instr: attr.getInstructions()) {
+ try {
++ for (InstructionDetailWriter w: detailWriters)
++ w.writeDetails(instr);
+ writeInstr(instr);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ println(report("error at or after byte " + instr.getPC()));
+ break;
+ }
+ }
++
++ for (InstructionDetailWriter w: detailWriters)
++ w.flush();
+ }
+
+ public void writeInstr(Instruction instr) {
+@@ -213,11 +226,45 @@
+ constantWriter.write(index);
+ }
+
+- private static int align(int n) {
+- return (n + 3) & ~3;
++ private List<InstructionDetailWriter> getDetailWriters(Code_attribute attr) {
++ List<InstructionDetailWriter> detailWriters =
++ new ArrayList<InstructionDetailWriter>();
++ if (options.details.contains(InstructionDetailWriter.Kind.SOURCE)) {
++ sourceWriter.reset(classWriter.getClassFile(), attr);
++ detailWriters.add(sourceWriter);
++ }
++
++ if (options.details.contains(InstructionDetailWriter.Kind.LOCAL_VARS)) {
++ localVariableTableWriter.reset(attr);
++ detailWriters.add(localVariableTableWriter);
++ }
++
++ if (options.details.contains(InstructionDetailWriter.Kind.LOCAL_VAR_TYPES)) {
++ localVariableTypeTableWriter.reset(attr);
++ detailWriters.add(localVariableTypeTableWriter);
++ }
++
++ if (options.details.contains(InstructionDetailWriter.Kind.STACKMAPS)) {
++ stackMapWriter.reset(attr);
++ stackMapWriter.writeInitialDetails();
++ detailWriters.add(stackMapWriter);
++ }
++
++ if (options.details.contains(InstructionDetailWriter.Kind.TRY_BLOCKS)) {
++ tryBlockWriter.reset(attr);
++ detailWriters.add(tryBlockWriter);
++ }
++
++ return detailWriters;
+ }
+
+ private AttributeWriter attrWriter;
+ private ClassWriter classWriter;
+ private ConstantWriter constantWriter;
++ private LocalVariableTableWriter localVariableTableWriter;
++ private LocalVariableTypeTableWriter localVariableTypeTableWriter;
++ private SourceWriter sourceWriter;
++ private StackMapWriter stackMapWriter;
++ private TryBlockWriter tryBlockWriter;
++ private Options options;
+ }
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java Tue May 19 11:50:54 2009 -0700
+@@ -0,0 +1,57 @@
++/*
++ * 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 com.sun.tools.javap;
++
++import com.sun.tools.classfile.Instruction;
++
++
++/*
++ * Write additional details for an instruction.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public abstract class InstructionDetailWriter extends BasicWriter {
++ public enum Kind {
++ LOCAL_VARS("localVariables"),
++ LOCAL_VAR_TYPES("localVariableTypes"),
++ SOURCE("source"),
++ STACKMAPS("stackMaps"),
++ TRY_BLOCKS("tryBlocks");
++ Kind(String option) {
++ this.option = option;
++ }
++ final String option;
++ }
++ InstructionDetailWriter(Context context) {
++ super(context);
++ }
++
++ abstract void writeDetails(Instruction instr);
++ void flush() { }
++}
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/JavapTask.java
+--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Jul 08 18:06:19 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue May 19 11:50:54 2009 -0700
+@@ -40,6 +40,7 @@
+ import java.text.MessageFormat;
+ import java.util.ArrayList;
+ import java.util.Arrays;
++import java.util.EnumSet;
+ import java.util.HashMap;
+ import java.util.Iterator;
+ import java.util.List;
+@@ -66,7 +67,7 @@
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+-public class JavapTask implements DisassemblerTool.DisassemblerTask {
++public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
+ public class BadArgs extends Exception {
+ static final long serialVersionUID = 8765093759964640721L;
+ BadArgs(String key, Object... args) {
+@@ -242,6 +243,56 @@
+ }
+ },
+
++ new Option(false, "-XDdetails") {
++ void process(JavapTask task, String opt, String arg) {
++ task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class);
++ }
++
++ },
++
++ new Option(false, "-XDdetails:") {
++ @Override
++ boolean matches(String opt) {
++ int sep = opt.indexOf(":");
++ return sep != -1 && super.matches(opt.substring(0, sep + 1));
++ }
++
++ void process(JavapTask task, String opt, String arg) throws BadArgs {
++ int sep = opt.indexOf(":");
++ for (String v: opt.substring(sep + 1).split("[,: ]+")) {
++ if (!handleArg(task, v))
++ throw task.new BadArgs("err.invalid.arg.for.option", v);
++ }
++ }
++
++ boolean handleArg(JavapTask task, String arg) {
++ if (arg.length() == 0)
++ return true;
++
++ if (arg.equals("all")) {
++ task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class);
++ return true;
++ }
++
++ boolean on = true;
++ if (arg.startsWith("-")) {
++ on = false;
++ arg = arg.substring(1);
++ }
++
++ for (InstructionDetailWriter.Kind k: InstructionDetailWriter.Kind.values()) {
++ if (arg.equalsIgnoreCase(k.option)) {
++ if (on)
++ task.options.details.add(k);
++ else
++ task.options.details.remove(k);
++ return true;
++ }
++ }
++ return false;
++ }
++ },
++
+ new Option(false, "-constants") {
+ void process(JavapTask task, String opt, String arg) {
+ task.options.showConstants = true;
+@@ -284,6 +335,7 @@
+
+ public JavapTask() {
+ context = new Context();
++ context.put(Messages.class, this);
+ options = Options.instance(context);
+ attributeFactory = new Attribute.Factory();
+ }
+@@ -489,6 +541,8 @@
+
+ context.put(PrintWriter.class, log);
+ ClassWriter classWriter = ClassWriter.instance(context);
++ SourceWriter sourceWriter = SourceWriter.instance(context);
++ sourceWriter.setFileManager(fileManager);
+
+ boolean ok = true;
+
+@@ -749,11 +803,11 @@
+
+ }
+
+- private String getMessage(String key, Object... args) {
++ public String getMessage(String key, Object... args) {
+ return getMessage(task_locale, key, args);
+ }
+
+- private String getMessage(Locale locale, String key, Object... args) {
++ public String getMessage(Locale locale, String key, Object... args) {
+ if (bundles == null) {
+ // could make this a HashMap<Locale,SoftReference<ResourceBundle>>
+ // and for efficiency, keep a hard reference to the bundle for the task
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/Messages.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/Messages.java Tue May 19 11:50:54 2009 -0700
+@@ -0,0 +1,42 @@
++/*
++ * Copyright 2007-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 com.sun.tools.javap;
++
++import java.util.Locale;
++
++/**
++ * Access to javap messages.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public interface Messages {
++ String getMessage(String key, Object... args);
++
++ String getMessage(Locale locale, String key, Object... args);
++}
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/Options.java
+--- langtools/src/share/classes/com/sun/tools/javap/Options.java Tue Jul 08 18:06:19 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/Options.java Tue May 19 11:50:54 2009 -0700
+@@ -25,8 +25,10 @@
+
+ package com.sun.tools.javap;
+
++import java.util.EnumSet;
+ import java.util.HashSet;
+ import java.util.Set;
++
+ import com.sun.tools.classfile.AccessFlags;
+
+ /*
+@@ -77,6 +79,7 @@
+ public boolean showLineAndLocalVariableTables;
+ public int showAccess;
+ public Set<String> accessOptions = new HashSet<String>();
++ public Set<InstructionDetailWriter.Kind> details = EnumSet.noneOf(InstructionDetailWriter.Kind.class);
+ public boolean showDisassembled;
+ public boolean showInternalSignatures;
+ public boolean showAllAttrs;
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/SourceWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/SourceWriter.java Tue May 19 11:50:54 2009 -0700
+@@ -0,0 +1,207 @@
++/*
++ * 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 com.sun.tools.javap;
++
++import java.io.BufferedReader;
++import java.io.IOException;
++import java.io.StringReader;
++import java.util.ArrayList;
++import java.util.List;
++import java.util.Set;
++import java.util.SortedMap;
++import java.util.SortedSet;
++import java.util.TreeMap;
++import java.util.TreeSet;
++import javax.tools.JavaFileManager;
++import javax.tools.JavaFileManager.Location;
++import javax.tools.JavaFileObject;
++import javax.tools.StandardLocation;
++
++import com.sun.tools.classfile.Attribute;
++import com.sun.tools.classfile.ClassFile;
++import com.sun.tools.classfile.Code_attribute;
++import com.sun.tools.classfile.ConstantPoolException;
++import com.sun.tools.classfile.Instruction;
++import com.sun.tools.classfile.LineNumberTable_attribute;
++import com.sun.tools.classfile.SourceFile_attribute;
++
++
++/**
++ * Annotate instructions with source code.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class SourceWriter extends InstructionDetailWriter {
++ static SourceWriter instance(Context context) {
++ SourceWriter instance = context.get(SourceWriter.class);
++ if (instance == null)
++ instance = new SourceWriter(context);
++ return instance;
++ }
++
++ protected SourceWriter(Context context) {
++ super(context);
++ context.put(SourceWriter.class, this);
++ }
++
++ void setFileManager(JavaFileManager fileManager) {
++ this.fileManager = fileManager;
++ }
++
++ public void reset(ClassFile cf, Code_attribute attr) {
++ setSource(cf);
++ setLineMap(attr);
++ }
++
++ public void writeDetails(Instruction instr) {
++ String indent = space(40); // could get from Options?
++ Set<Integer> lines = lineMap.get(instr.getPC());
++ if (lines != null) {
++ for (int line: lines) {
++ print(indent);
++ print(String.format(" %4d ", line));
++ if (line < sourceLines.length)
++ print(sourceLines[line]);
++ println();
++ int nextLine = nextLine(line);
++ for (int i = line + 1; i < nextLine; i++) {
++ print(indent);
++ print(String.format("(%4d)", i));
++ if (i < sourceLines.length)
++ print(sourceLines[i]);
++ println();
++ }
++ }
++ }
++
++ }
++
++ private void setLineMap(Code_attribute attr) {
++ SortedMap<Integer, SortedSet<Integer>> map =
++ new TreeMap<Integer, SortedSet<Integer>>();
++ SortedSet<Integer> allLines = new TreeSet<Integer>();
++ for (Attribute a: attr.attributes) {
++ if (a instanceof LineNumberTable_attribute) {
++ LineNumberTable_attribute t = (LineNumberTable_attribute) a;
++ for (LineNumberTable_attribute.Entry e: t.line_number_table) {
++ int start_pc = e.start_pc;
++ int line = e.line_number;
++ SortedSet<Integer> pcLines = map.get(start_pc);
++ if (pcLines == null) {
++ pcLines = new TreeSet<Integer>();
++ map.put(start_pc, pcLines);
++ }
++ pcLines.add(line);
++ allLines.add(line);
++ }
++ }
++ }
++ lineMap = map;
++ lineList = new ArrayList<Integer>(allLines);
++ }
++
++ private void setSource(ClassFile cf) {
++ if (cf != classFile) {
++ classFile = cf;
++ sourceLines = splitLines(readSource(cf));
++ }
++ }
++
++ private String readSource(ClassFile cf) {
++ Location location;
++ if (fileManager.hasLocation((StandardLocation.SOURCE_PATH)))
++ location = StandardLocation.SOURCE_PATH;
++ else
++ location = StandardLocation.CLASS_PATH;
++
++ // Guess the source file for a class from the package name for this
++ // class and the base of the source file. This avoids having to read
++ // additional classes to determine the outmost class from any
++ // InnerClasses and EnclosingMethod attributes.
++ try {
++ String className = cf.getName();
++ SourceFile_attribute sf =
++ (SourceFile_attribute) cf.attributes.get(Attribute.SourceFile);
++ if (sf == null) {
++ report(messages.getMessage("err.no.SourceFile.attribute"));
++ return null;
++ }
++ String sourceFile = sf.getSourceFile(cf.constant_pool);
++ String fileBase = sourceFile.endsWith(".java")
++ ? sourceFile.substring(0, sourceFile.length() - 5) : sourceFile;
++ int sep = className.lastIndexOf("/");
++ String pkgName = (sep == -1 ? "" : className.substring(0, sep+1));
++ String topClassName = (pkgName + fileBase).replace('/', '.');
++ JavaFileObject fo =
++ fileManager.getJavaFileForInput(location,
++ topClassName,
++ JavaFileObject.Kind.SOURCE);
++ if (fo == null) {
++ report(messages.getMessage("err.source.file.not.found"));
++ return null;
++ }
++ return fo.getCharContent(true).toString();
++ } catch (ConstantPoolException e) {
++ report(e);
++ return null;
++ } catch (IOException e) {
++ report(e.getLocalizedMessage());
++ return null;
++ }
++ }
++
++ private static String[] splitLines(String text) {
++ if (text == null)
++ return new String[0];
++
++ List<String> lines = new ArrayList<String>();
++ lines.add(""); // dummy line 0
++ try {
++ BufferedReader r = new BufferedReader(new StringReader(text));
++ String line;
++ while ((line = r.readLine()) != null)
++ lines.add(line);
++ } catch (IOException ignore) {
++ }
++ return lines.toArray(new String[lines.size()]);
++ }
++
++ private int nextLine(int line) {
++ int i = lineList.indexOf(line);
++ if (i == -1 || i == lineList.size() - 1)
++ return - 1;
++ return lineList.get(i + 1);
++ }
++
++ private JavaFileManager fileManager;
++ private ClassFile classFile;
++ private SortedMap<Integer, SortedSet<Integer>> lineMap;
++ private List<Integer> lineList;
++ private String[] sourceLines;
++}
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/StackMapWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/StackMapWriter.java Tue May 19 11:50:54 2009 -0700
+@@ -0,0 +1,291 @@
++/*
++ * 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 com.sun.tools.javap;
++
++import com.sun.tools.classfile.AccessFlags;
++import java.util.HashMap;
++import java.util.Map;
++
++import com.sun.tools.classfile.Attribute;
++import com.sun.tools.classfile.Code_attribute;
++import com.sun.tools.classfile.ConstantPool;
++import com.sun.tools.classfile.ConstantPoolException;
++import com.sun.tools.classfile.Descriptor;
++import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
++import com.sun.tools.classfile.Instruction;
++import com.sun.tools.classfile.Method;
++import com.sun.tools.classfile.StackMapTable_attribute;
++import com.sun.tools.classfile.StackMapTable_attribute.*;
++
++import static com.sun.tools.classfile.StackMapTable_attribute.verification_type_info.*;
++
++/**
++ * Annotate instructions with stack map.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class StackMapWriter extends InstructionDetailWriter {
++ static StackMapWriter instance(Context context) {
++ StackMapWriter instance = context.get(StackMapWriter.class);
++ if (instance == null)
++ instance = new StackMapWriter(context);
++ return instance;
++ }
++
++ protected StackMapWriter(Context context) {
++ super(context);
++ context.put(StackMapWriter.class, this);
++ classWriter = ClassWriter.instance(context);
++ }
++
++ public void reset(Code_attribute attr) {
++ setStackMap((StackMapTable_attribute) attr.attributes.get(Attribute.StackMapTable));
++ }
++
++ void setStackMap(StackMapTable_attribute attr) {
++ if (attr == null) {
++ map = null;
++ return;
++ }
++
++ Method m = classWriter.getMethod();
++ Descriptor d = m.descriptor;
++ String[] args;
++ try {
++ ConstantPool cp = classWriter.getClassFile().constant_pool;
++ String argString = d.getParameterTypes(cp);
++ args = argString.substring(1, argString.length() - 1).split("[, ]+");
++ } catch (ConstantPoolException e) {
++ return;
++ } catch (InvalidDescriptor e) {
++ return;
++ }
++ boolean isStatic = m.access_flags.is(AccessFlags.ACC_STATIC);
++
++ verification_type_info[] initialLocals = new verification_type_info[(isStatic ? 0 : 1) + args.length];
++ if (!isStatic)
++ initialLocals[0] = new CustomVerificationTypeInfo("this");
++ for (int i = 0; i < args.length; i++) {
++ initialLocals[(isStatic ? 0 : 1) + i] =
++ new CustomVerificationTypeInfo(args[i].replace(".", "/"));
++ }
++
++ map = new HashMap<Integer, StackMap>();
++ StackMapBuilder builder = new StackMapBuilder();
++
++ // using -1 as the pc for the initial frame effectively compensates for
++ // the difference in behavior for the first stack map frame (where the
++ // pc offset is just offset_delta) compared to subsequent frames (where
++ // the pc offset is always offset_delta+1).
++ int pc = -1;
++
++ map.put(pc, new StackMap(initialLocals, empty));
++
++ for (int i = 0; i < attr.entries.length; i++)
++ pc = attr.entries[i].accept(builder, pc);
++ }
++
++ public void writeInitialDetails() {
++ writeDetails(-1);
++ }
++
++ public void writeDetails(Instruction instr) {
++ writeDetails(instr.getPC());
++ }
++
++ private void writeDetails(int pc) {
++ if (map == null)
++ return;
++
++ StackMap m = map.get(pc);
++ if (m != null) {
++ print("StackMap locals: ", m.locals);
++ print("StackMap stack: ", m.stack);
++ }
++
++ }
++
++ void print(String label, verification_type_info[] entries) {
++ print(label);
++ for (int i = 0; i < entries.length; i++) {
++ print(" ");
++ print(entries[i]);
++ }
++ println();
++ }
++
++ void print(verification_type_info entry) {
++ if (entry == null) {
++ print("ERROR");
++ return;
++ }
++
++ switch (entry.tag) {
++ case -1:
++ print(((CustomVerificationTypeInfo) entry).text);
++ break;
++
++ case ITEM_Top:
++ print("top");
++ break;
++
++ case ITEM_Integer:
++ print("int");
++ break;
++
++ case ITEM_Float:
++ print("float");
++ break;
++
++ case ITEM_Long:
++ print("long");
++ break;
++
++ case ITEM_Double:
++ print("double");
++ break;
++
++ case ITEM_Null:
++ print("null");
++ break;
++
++ case ITEM_UninitializedThis:
++ print("uninit_this");
++ break;
++
++ case ITEM_Object:
++ try {
++ ConstantPool cp = classWriter.getClassFile().constant_pool;
++ ConstantPool.CONSTANT_Class_info class_info = cp.getClassInfo(((Object_variable_info) entry).cpool_index);
++ print(cp.getUTF8Value(class_info.name_index));
++ } catch (ConstantPoolException e) {
++ print("??");
++ }
++ break;
++
++ case ITEM_Uninitialized:
++ print(((Uninitialized_variable_info) entry).offset);
++ break;
++ }
++
++ }
++
++ private Map<Integer, StackMap> map;
++ private ClassWriter classWriter;
++
++ class StackMapBuilder
++ implements StackMapTable_attribute.stack_map_frame.Visitor<Integer, Integer> {
++
++ public Integer visit_same_frame(same_frame frame, Integer pc) {
++ int new_pc = pc + frame.getOffsetDelta() + 1;
++ StackMap m = map.get(pc);
++ assert (m != null);
++ map.put(new_pc, m);
++ return new_pc;
++ }
++
++ public Integer visit_same_locals_1_stack_item_frame(same_locals_1_stack_item_frame frame, Integer pc) {
++ int new_pc = pc + frame.getOffsetDelta() + 1;
++ StackMap prev = map.get(pc);
++ assert (prev != null);
++ StackMap m = new StackMap(prev.locals, frame.stack);
++ map.put(new_pc, m);
++ return new_pc;
++ }
++
++ public Integer visit_same_locals_1_stack_item_frame_extended(same_locals_1_stack_item_frame_extended frame, Integer pc) {
++ int new_pc = pc + frame.getOffsetDelta() + 1;
++ StackMap prev = map.get(pc);
++ assert (prev != null);
++ StackMap m = new StackMap(prev.locals, frame.stack);
++ map.put(new_pc, m);
++ return new_pc;
++ }
++
++ public Integer visit_chop_frame(chop_frame frame, Integer pc) {
++ int new_pc = pc + frame.getOffsetDelta() + 1;
++ StackMap prev = map.get(pc);
++ assert (prev != null);
++ int k = 251 - frame.frame_type;
++ verification_type_info[] new_locals = new verification_type_info[prev.locals.length - k];
++ System.arraycopy(prev.locals, 0, new_locals, 0, new_locals.length);
++ StackMap m = new StackMap(new_locals, empty);
++ map.put(new_pc, m);
++ return new_pc;
++ }
++
++ public Integer visit_same_frame_extended(same_frame_extended frame, Integer pc) {
++ int new_pc = pc + frame.getOffsetDelta();
++ StackMap m = map.get(pc);
++ assert (m != null);
++ map.put(new_pc, m);
++ return new_pc;
++ }
++
++ public Integer visit_append_frame(append_frame frame, Integer pc) {
++ int new_pc = pc + frame.getOffsetDelta() + 1;
++ StackMap prev = map.get(pc);
++ assert (prev != null);
++ verification_type_info[] new_locals = new verification_type_info[prev.locals.length + frame.locals.length];
++ System.arraycopy(prev.locals, 0, new_locals, 0, prev.locals.length);
++ System.arraycopy(frame.locals, 0, new_locals, prev.locals.length, frame.locals.length);
++ StackMap m = new StackMap(new_locals, empty);
++ map.put(new_pc, m);
++ return new_pc;
++ }
++
++ public Integer visit_full_frame(full_frame frame, Integer pc) {
++ int new_pc = pc + frame.getOffsetDelta() + 1;
++ StackMap m = new StackMap(frame.locals, frame.stack);
++ map.put(new_pc, m);
++ return new_pc;
++ }
++
++ }
++
++ class StackMap {
++ StackMap(verification_type_info[] locals, verification_type_info[] stack) {
++ this.locals = locals;
++ this.stack = stack;
++ }
++
++ private final verification_type_info[] locals;
++ private final verification_type_info[] stack;
++ }
++
++ class CustomVerificationTypeInfo extends verification_type_info {
++ public CustomVerificationTypeInfo(String text) {
++ super(-1);
++ this.text = text;
++ }
++ private String text;
++ }
++
++ private final verification_type_info[] empty = { };
++}
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/TryBlockWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/TryBlockWriter.java Tue May 19 11:50:54 2009 -0700
+@@ -0,0 +1,142 @@
++/*
++ * 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 com.sun.tools.javap;
++
++import com.sun.tools.classfile.Code_attribute;
++import com.sun.tools.classfile.Code_attribute.Exception_data;
++import com.sun.tools.classfile.Instruction;
++import java.util.ArrayList;
++import java.util.HashMap;
++import java.util.List;
++import java.util.ListIterator;
++import java.util.Map;
++
++/**
++ * Annotate instructions with details about try blocks.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class TryBlockWriter extends InstructionDetailWriter {
++ public enum NoteKind {
++ START("try") {
++ public boolean match(Exception_data entry, int pc) {
++ return (pc == entry.start_pc);
++ }
++ },
++ END("end try") {
++ public boolean match(Exception_data entry, int pc) {
++ return (pc == entry.end_pc);
++ }
++ },
++ HANDLER("catch") {
++ public boolean match(Exception_data entry, int pc) {
++ return (pc == entry.handler_pc);
++ }
++ };
++ NoteKind(String text) {
++ this.text = text;
++ }
++ public abstract boolean match(Exception_data entry, int pc);
++ public final String text;
++ };
++
++ static TryBlockWriter instance(Context context) {
++ TryBlockWriter instance = context.get(TryBlockWriter.class);
++ if (instance == null)
++ instance = new TryBlockWriter(context);
++ return instance;
++ }
++
++ protected TryBlockWriter(Context context) {
++ super(context);
++ context.put(TryBlockWriter.class, this);
++ constantWriter = ConstantWriter.instance(context);
++ }
++
++ public void reset(Code_attribute attr) {
++ indexMap = new HashMap<Exception_data, Integer>();
++ pcMap = new HashMap<Integer, List<Exception_data>>();
++ for (int i = 0; i < attr.exception_table.length; i++) {
++ Exception_data entry = attr.exception_table[i];
++ indexMap.put(entry, i);
++ put(entry.start_pc, entry);
++ put(entry.end_pc, entry);
++ put(entry.handler_pc, entry);
++ }
++ }
++
++ public void writeDetails(Instruction instr) {
++ writeTrys(instr, NoteKind.END);
++ writeTrys(instr, NoteKind.START);
++ writeTrys(instr, NoteKind.HANDLER);
++ }
++
++ public void writeTrys(Instruction instr, NoteKind kind) {
++ String indent = space(2); // get from Options?
++ int pc = instr.getPC();
++ List<Exception_data> entries = pcMap.get(pc);
++ if (entries != null) {
++ for (ListIterator<Exception_data> iter =
++ entries.listIterator(kind == NoteKind.END ? entries.size() : 0);
++ kind == NoteKind.END ? iter.hasPrevious() : iter.hasNext() ; ) {
++ Exception_data entry =
++ kind == NoteKind.END ? iter.previous() : iter.next();
++ if (kind.match(entry, pc)) {
++ print(indent);
++ print(kind.text);
++ print("[");
++ print(indexMap.get(entry));
++ print("] ");
++ if (entry.catch_type == 0)
++ print("finally");
++ else {
++ print("#" + entry.catch_type);
++ print(" // ");
++ constantWriter.write(entry.catch_type);
++ }
++ println();
++ }
++ }
++ }
++ }
++
++ private void put(int pc, Exception_data entry) {
++ List<Exception_data> list = pcMap.get(pc);
++ if (list == null) {
++ list = new ArrayList<Exception_data>();
++ pcMap.put(pc, list);
++ }
++ if (!list.contains(entry))
++ list.add(entry);
++ }
++
++ private Map<Integer, List<Exception_data>> pcMap;
++ private Map<Exception_data, Integer> indexMap;
++ private ConstantWriter constantWriter;
++}
+diff -r 8f5d8429b3f1 -r 4b55db11179d src/share/classes/com/sun/tools/javap/resources/javap.properties
+--- langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue Jul 08 18:06:19 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue May 19 11:50:54 2009 -0700
+@@ -9,6 +9,7 @@
+ err.h.not.supported=-h is no longer available - use the 'javah' program
+ err.incompatible.options=bad combination of options: {0}
+ err.internal.error=internal error: {0} {1} {2}
++err.invalid.arg.for.option=invalid argument for option: {0}
+ err.ioerror=IO error reading {0}: {1}
+ err.missing.arg=no value given for {0}
+ err.no.classes.specified=no classes specified
+@@ -16,6 +17,8 @@
+ err.unknown.option=unknown option: {0}
+ err.verify.not.supported=-verify not supported
+ err.Xold.not.supported.here=-Xold must be given as the first option
++err.no.SourceFile.attribute=no SourceFile attribute
++err.source.file.not.found=source file not found
+
+ main.usage=\
+ Usage: {0} <options> <classes>\n\
+diff -r 8f5d8429b3f1 -r 4b55db11179d test/tools/javap/T6824493.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T6824493.java Tue May 19 11:50:54 2009 -0700
+@@ -0,0 +1,116 @@
++/*
++ * 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.
++ */
++
++import java.io.*;
++import java.util.*;
++
++/*
++ * @test
++ * @bug 6824493
++ * @summary experimental support for additional info for instructions
++ * @compile -g T6824493.java
++ * @run main T6824493
++ */
++public class T6824493 {
++ public static void main(String... args) {
++ new T6824493().run();
++ }
++
++ void run() {
++ // for each of the options, we run javap and check for some
++ // marker strings in the output that generally indicate the
++ // presence of the expected output, without being as specific
++ // as a full golden file test.
++ test("-XDdetails:source",
++ "for (int i = 0; i < 10; i++) {",
++ "System.out.println(s + i);");
++
++ test("-XDdetails:tryBlocks",
++ "try[0]",
++ "end try[0]",
++ "catch[0]");
++
++ test("-XDdetails:stackMaps",
++ "StackMap locals: this java/lang/String int",
++ "StackMap stack: java/lang/Throwable");
++
++ test("-XDdetails:localVariables",
++ "start local 3 // java.util.List list",
++ "end local 3 // java.util.List list");
++
++ test("-XDdetails:localVariableTypes",
++ "start generic local 3 // java.util.List<java.lang.String> list",
++ "end generic local 3 // java.util.List<java.lang.String> list");
++
++ if (errors > 0)
++ throw new Error(errors + " errors found");
++ }
++
++ void test(String option, String... expect) {
++ String[] args = {
++ "-c",
++ "-classpath",
++ testSrc + File.pathSeparator + testClasses,
++ option,
++ "Test"
++ };
++ StringWriter sw = new StringWriter();
++ PrintWriter pw = new PrintWriter(sw);
++ int rc = com.sun.tools.javap.Main.run(args, pw);
++ if (rc != 0) {
++ error("unexpected return code from javap: " + rc);
++ return;
++ }
++
++ String out = sw.toString();
++ System.out.println(out);
++ for (String e: expect) {
++ if (!out.contains(e))
++ error("Not found: " + e);
++ }
++ }
++
++ void error(String msg) {
++ System.err.println("Error: " + msg);
++ errors++;
++ }
++
++ private int errors;
++ private String testSrc = System.getProperty("test.src", ".");
++ private String testClasses = System.getProperty("test.classes", ".");
++}
++
++class Test {
++ void m(String s) {
++ for (int i = 0; i < 10; i++) {
++ try {
++ List<String> list = null;
++ System.out.println(s + i);
++ } catch (NullPointerException e) {
++ System.out.println("catch NPE");
++ } finally {
++ System.out.println("finally");
++ }
++ }
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/6841419-classfile_iterator.patch b/java/openjdk6/files/icedtea/openjdk/6841419-classfile_iterator.patch
new file mode 100644
index 000000000000..f728ad179600
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6841419-classfile_iterator.patch
@@ -0,0 +1,142 @@
+# HG changeset patch
+# User jjg
+# Date 1242758630 25200
+# Tue May 19 11:43:50 2009 -0700
+# Node ID 17dfaebe23044c48bcd5ed0730ce2358543ac459
+# Parent 00870be9028f778a169bf9b843a994ec44258c22
+6841419: classfile: add constant pool iterator
+Reviewed-by: mcimadamore
+
+diff -r 00870be9028f -r 17dfaebe2304 src/share/classes/com/sun/tools/classfile/ClassTranslator.java
+--- langtools/src/share/classes/com/sun/tools/classfile/ClassTranslator.java Tue May 19 11:33:13 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/classfile/ClassTranslator.java Tue May 19 11:43:50 2009 -0700
+@@ -95,7 +95,7 @@
+ if (cp2 == null) {
+ ConstantPool.CPInfo[] pool2 = new ConstantPool.CPInfo[cp.size()];
+ boolean eq = true;
+- for (int i = 0; i < cp.size(); i++) {
++ for (int i = 0; i < cp.size(); ) {
+ ConstantPool.CPInfo cpInfo;
+ try {
+ cpInfo = cp.get(i);
+@@ -107,11 +107,7 @@
+ pool2[i] = cpInfo2;
+ if (cpInfo.getTag() != cpInfo2.getTag())
+ throw new IllegalStateException();
+- switch (cpInfo.getTag()) {
+- case ConstantPool.CONSTANT_Double:
+- case ConstantPool.CONSTANT_Long:
+- i += 1;
+- }
++ i += cpInfo.size();
+ }
+
+ if (eq)
+diff -r 00870be9028f -r 17dfaebe2304 src/share/classes/com/sun/tools/classfile/ClassWriter.java
+--- langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java Tue May 19 11:33:13 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java Tue May 19 11:43:50 2009 -0700
+@@ -118,13 +118,8 @@
+ ConstantPool pool = classFile.constant_pool;
+ int size = pool.size();
+ out.writeShort(size);
+- try {
+- for (int i = 1; i < size; ) {
+- i += constantPoolWriter.write(pool.get(i), out);
+- }
+- } catch (ConstantPoolException e) {
+- throw new Error(e); // ??
+- }
++ for (CPInfo cpInfo: pool.entries())
++ constantPoolWriter.write(cpInfo, out);
+ }
+
+ protected void writeFields() throws IOException {
+diff -r 00870be9028f -r 17dfaebe2304 src/share/classes/com/sun/tools/classfile/ConstantPool.java
+--- langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Tue May 19 11:33:13 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Tue May 19 11:43:50 2009 -0700
+@@ -26,6 +26,7 @@
+ package com.sun.tools.classfile;
+
+ import java.io.IOException;
++import java.util.Iterator;
+
+ /**
+ * See JVMS3, section 4.5.
+@@ -219,6 +220,40 @@
+ throw new EntryNotFound(value);
+ }
+
++ public Iterable<CPInfo> entries() {
++ return new Iterable<CPInfo>() {
++ public Iterator<CPInfo> iterator() {
++ return new Iterator<CPInfo>() {
++
++ public boolean hasNext() {
++ return next < pool.length;
++ }
++
++ public CPInfo next() {
++ current = pool[next];
++ switch (current.getTag()) {
++ case CONSTANT_Double:
++ case CONSTANT_Long:
++ next += 2;
++ break;
++ default:
++ next += 1;
++ }
++ return current;
++ }
++
++ public void remove() {
++ throw new UnsupportedOperationException();
++ }
++
++ private CPInfo current;
++ private int next = 1;
++
++ };
++ }
++ };
++ }
++
+ private CPInfo[] pool;
+
+ public interface Visitor<R,P> {
+@@ -246,6 +281,12 @@
+
+ public abstract int getTag();
+
++ /** The number of slots in the constant pool used by this entry.
++ * 2 for CONSTANT_Double and CONSTANT_Long; 1 for everything else. */
++ public int size() {
++ return 1;
++ }
++
+ public abstract <R,D> R accept(Visitor<R,D> visitor, D data);
+
+ protected final ConstantPool cp;
+@@ -346,6 +387,11 @@
+ }
+
+ @Override
++ public int size() {
++ return 2;
++ }
++
++ @Override
+ public String toString() {
+ return "CONSTANT_Double_info[value: " + value + "]";
+ }
+@@ -459,6 +505,11 @@
+ }
+
+ @Override
++ public int size() {
++ return 2;
++ }
++
++ @Override
+ public String toString() {
+ return "CONSTANT_Long_info[value: " + value + "]";
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/6841420-classfile_methods.patch b/java/openjdk6/files/icedtea/openjdk/6841420-classfile_methods.patch
new file mode 100644
index 000000000000..340286a63187
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6841420-classfile_methods.patch
@@ -0,0 +1,34 @@
+# HG changeset patch
+# User jjg
+# Date 1242757993 25200
+# Tue May 19 11:33:13 2009 -0700
+# Node ID 00870be9028f778a169bf9b843a994ec44258c22
+# Parent c9b0fee44d446f902102462387c40ca9d1020b6e
+6841420: classfile: add new methods to ConstantClassInfo
+Reviewed-by: mcimadamore
+Contributed-by: kevin.t.looney@sun.com
+
+diff -r c9b0fee44d44 -r 00870be9028f src/share/classes/com/sun/tools/classfile/ConstantPool.java
+--- langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Wed Jun 18 16:53:08 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Tue May 19 11:33:13 2009 -0700
+@@ -306,6 +306,20 @@
+ return cp.getUTF8Value(name_index);
+ }
+
++ public String getBaseName() throws ConstantPoolException {
++ String name = getName();
++ int index = name.indexOf("[L") + 1;
++ return name.substring(index);
++ }
++
++ public int getDimensionCount() throws ConstantPoolException {
++ String name = getName();
++ int count = 0;
++ while (name.charAt(count) == '[')
++ count++;
++ return count;
++ }
++
+ @Override
+ public String toString() {
+ return "CONSTANT_Class_info[name_index: " + name_index + "]";
diff --git a/java/openjdk6/files/icedtea/openjdk/6843013-missing_experimental.patch b/java/openjdk6/files/icedtea/openjdk/6843013-missing_experimental.patch
new file mode 100644
index 000000000000..b4f5c1dcfc01
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6843013-missing_experimental.patch
@@ -0,0 +1,334 @@
+# HG changeset patch
+# User jjg
+# Date 1242766380 25200
+# Tue May 19 13:53:00 2009 -0700
+# Node ID a7567fdabf3eae2c495726e6c25e2364e175261f
+# Parent 4b55db11179d066331b829ca5c4722c33287deea
+6843013: missing files in fix for 6824493
+Reviewed-by: darcy
+
+diff -r 4b55db11179d -r a7567fdabf3e src/share/classes/com/sun/tools/javap/LocalVariableTableWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/LocalVariableTableWriter.java Tue May 19 13:53:00 2009 -0700
+@@ -0,0 +1,158 @@
++/*
++ * 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 com.sun.tools.javap;
++
++import com.sun.tools.classfile.Attribute;
++import com.sun.tools.classfile.Code_attribute;
++import com.sun.tools.classfile.ConstantPool;
++import com.sun.tools.classfile.ConstantPoolException;
++import com.sun.tools.classfile.Descriptor;
++import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
++import com.sun.tools.classfile.Instruction;
++import com.sun.tools.classfile.LocalVariableTable_attribute;
++import java.util.ArrayList;
++import java.util.HashMap;
++import java.util.List;
++import java.util.ListIterator;
++import java.util.Map;
++
++/**
++ * Annotate instructions with details about local variables.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class LocalVariableTableWriter extends InstructionDetailWriter {
++ public enum NoteKind {
++ START("start") {
++ public boolean match(LocalVariableTable_attribute.Entry entry, int pc) {
++ return (pc == entry.start_pc);
++ }
++ },
++ END("end") {
++ public boolean match(LocalVariableTable_attribute.Entry entry, int pc) {
++ return (pc == entry.start_pc + entry.length);
++ }
++ };
++ NoteKind(String text) {
++ this.text = text;
++ }
++ public abstract boolean match(LocalVariableTable_attribute.Entry entry, int pc);
++ public final String text;
++ };
++
++ static LocalVariableTableWriter instance(Context context) {
++ LocalVariableTableWriter instance = context.get(LocalVariableTableWriter.class);
++ if (instance == null)
++ instance = new LocalVariableTableWriter(context);
++ return instance;
++ }
++
++ protected LocalVariableTableWriter(Context context) {
++ super(context);
++ context.put(LocalVariableTableWriter.class, this);
++ classWriter = ClassWriter.instance(context);
++ }
++
++ public void reset(Code_attribute attr) {
++ codeAttr = attr;
++ pcMap = new HashMap<Integer, List<LocalVariableTable_attribute.Entry>>();
++ LocalVariableTable_attribute lvt =
++ (LocalVariableTable_attribute) (attr.attributes.get(Attribute.LocalVariableTable));
++ if (lvt == null)
++ return;
++
++ for (int i = 0; i < lvt.local_variable_table.length; i++) {
++ LocalVariableTable_attribute.Entry entry = lvt.local_variable_table[i];
++ put(entry.start_pc, entry);
++ put(entry.start_pc + entry.length, entry);
++ }
++ }
++
++ public void writeDetails(Instruction instr) {
++ int pc = instr.getPC();
++ writeLocalVariables(pc, NoteKind.END);
++ writeLocalVariables(pc, NoteKind.START);
++ }
++
++ @Override
++ public void flush() {
++ int pc = codeAttr.code_length;
++ writeLocalVariables(pc, NoteKind.END);
++ }
++
++ public void writeLocalVariables(int pc, NoteKind kind) {
++ ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
++ String indent = space(2); // get from Options?
++ List<LocalVariableTable_attribute.Entry> entries = pcMap.get(pc);
++ if (entries != null) {
++ for (ListIterator<LocalVariableTable_attribute.Entry> iter =
++ entries.listIterator(kind == NoteKind.END ? entries.size() : 0);
++ kind == NoteKind.END ? iter.hasPrevious() : iter.hasNext() ; ) {
++ LocalVariableTable_attribute.Entry entry =
++ kind == NoteKind.END ? iter.previous() : iter.next();
++ if (kind.match(entry, pc)) {
++ print(indent);
++ print(kind.text);
++ print(" local ");
++ print(entry.index);
++ print(" // ");
++ Descriptor d = new Descriptor(entry.descriptor_index);
++ try {
++ print(d.getFieldType(constant_pool));
++ } catch (InvalidDescriptor e) {
++ print(report(e));
++ } catch (ConstantPoolException e) {
++ print(report(e));
++ }
++ print(" ");
++ try {
++ print(constant_pool.getUTF8Value(entry.name_index));
++ } catch (ConstantPoolException e) {
++ print(report(e));
++ }
++ println();
++ }
++ }
++ }
++ }
++
++ private void put(int pc, LocalVariableTable_attribute.Entry entry) {
++ List<LocalVariableTable_attribute.Entry> list = pcMap.get(pc);
++ if (list == null) {
++ list = new ArrayList<LocalVariableTable_attribute.Entry>();
++ pcMap.put(pc, list);
++ }
++ if (!list.contains(entry))
++ list.add(entry);
++ }
++
++ private ClassWriter classWriter;
++ private Code_attribute codeAttr;
++ private Map<Integer, List<LocalVariableTable_attribute.Entry>> pcMap;
++}
+diff -r 4b55db11179d -r a7567fdabf3e src/share/classes/com/sun/tools/javap/LocalVariableTypeTableWriter.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/src/share/classes/com/sun/tools/javap/LocalVariableTypeTableWriter.java Tue May 19 13:53:00 2009 -0700
+@@ -0,0 +1,159 @@
++/*
++ * 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 com.sun.tools.javap;
++
++import com.sun.tools.classfile.Attribute;
++import com.sun.tools.classfile.Code_attribute;
++import com.sun.tools.classfile.ConstantPool;
++import com.sun.tools.classfile.ConstantPoolException;
++import com.sun.tools.classfile.Descriptor;
++import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
++import com.sun.tools.classfile.Instruction;
++import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
++import com.sun.tools.classfile.Signature;
++import java.util.ArrayList;
++import java.util.HashMap;
++import java.util.List;
++import java.util.ListIterator;
++import java.util.Map;
++
++/**
++ * Annotate instructions with details about local variables.
++ *
++ * <p><b>This is NOT part of any API supported by Sun Microsystems. If
++ * you write code that depends on this, you do so at your own risk.
++ * This code and its internal interfaces are subject to change or
++ * deletion without notice.</b>
++ */
++public class LocalVariableTypeTableWriter extends InstructionDetailWriter {
++ public enum NoteKind {
++ START("start") {
++ public boolean match(LocalVariableTypeTable_attribute.Entry entry, int pc) {
++ return (pc == entry.start_pc);
++ }
++ },
++ END("end") {
++ public boolean match(LocalVariableTypeTable_attribute.Entry entry, int pc) {
++ return (pc == entry.start_pc + entry.length);
++ }
++ };
++ NoteKind(String text) {
++ this.text = text;
++ }
++ public abstract boolean match(LocalVariableTypeTable_attribute.Entry entry, int pc);
++ public final String text;
++ };
++
++ static LocalVariableTypeTableWriter instance(Context context) {
++ LocalVariableTypeTableWriter instance = context.get(LocalVariableTypeTableWriter.class);
++ if (instance == null)
++ instance = new LocalVariableTypeTableWriter(context);
++ return instance;
++ }
++
++ protected LocalVariableTypeTableWriter(Context context) {
++ super(context);
++ context.put(LocalVariableTypeTableWriter.class, this);
++ classWriter = ClassWriter.instance(context);
++ }
++
++ public void reset(Code_attribute attr) {
++ codeAttr = attr;
++ pcMap = new HashMap<Integer, List<LocalVariableTypeTable_attribute.Entry>>();
++ LocalVariableTypeTable_attribute lvt =
++ (LocalVariableTypeTable_attribute) (attr.attributes.get(Attribute.LocalVariableTypeTable));
++ if (lvt == null)
++ return;
++
++ for (int i = 0; i < lvt.local_variable_table.length; i++) {
++ LocalVariableTypeTable_attribute.Entry entry = lvt.local_variable_table[i];
++ put(entry.start_pc, entry);
++ put(entry.start_pc + entry.length, entry);
++ }
++ }
++
++ public void writeDetails(Instruction instr) {
++ int pc = instr.getPC();
++ writeLocalVariables(pc, NoteKind.END);
++ writeLocalVariables(pc, NoteKind.START);
++ }
++
++ @Override
++ public void flush() {
++ int pc = codeAttr.code_length;
++ writeLocalVariables(pc, NoteKind.END);
++ }
++
++ public void writeLocalVariables(int pc, NoteKind kind) {
++ ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
++ String indent = space(2); // get from Options?
++ List<LocalVariableTypeTable_attribute.Entry> entries = pcMap.get(pc);
++ if (entries != null) {
++ for (ListIterator<LocalVariableTypeTable_attribute.Entry> iter =
++ entries.listIterator(kind == NoteKind.END ? entries.size() : 0);
++ kind == NoteKind.END ? iter.hasPrevious() : iter.hasNext() ; ) {
++ LocalVariableTypeTable_attribute.Entry entry =
++ kind == NoteKind.END ? iter.previous() : iter.next();
++ if (kind.match(entry, pc)) {
++ print(indent);
++ print(kind.text);
++ print(" generic local ");
++ print(entry.index);
++ print(" // ");
++ Descriptor d = new Signature(entry.signature_index);
++ try {
++ print(d.getFieldType(constant_pool));
++ } catch (InvalidDescriptor e) {
++ print(report(e));
++ } catch (ConstantPoolException e) {
++ print(report(e));
++ }
++ print(" ");
++ try {
++ print(constant_pool.getUTF8Value(entry.name_index));
++ } catch (ConstantPoolException e) {
++ print(report(e));
++ }
++ println();
++ }
++ }
++ }
++ }
++
++ private void put(int pc, LocalVariableTypeTable_attribute.Entry entry) {
++ List<LocalVariableTypeTable_attribute.Entry> list = pcMap.get(pc);
++ if (list == null) {
++ list = new ArrayList<LocalVariableTypeTable_attribute.Entry>();
++ pcMap.put(pc, list);
++ }
++ if (!list.contains(entry))
++ list.add(entry);
++ }
++
++ private ClassWriter classWriter;
++ private Code_attribute codeAttr;
++ private Map<Integer, List<LocalVariableTypeTable_attribute.Entry>> pcMap;
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/6852856-javap_subclasses.patch b/java/openjdk6/files/icedtea/openjdk/6852856-javap_subclasses.patch
new file mode 100644
index 000000000000..60b1405cd011
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6852856-javap_subclasses.patch
@@ -0,0 +1,508 @@
+# HG changeset patch
+# User jjg
+# Date 1382677646 -3600
+# Fri Oct 25 06:07:26 2013 +0100
+# Node ID a22d1b683f15e7f67d7d3de84f7c866a65c42552
+# Parent dca34170f5f80bf30228c12a647b3f1a492b3eeb
+6852856: javap changes to facilitate subclassing javap for variants
+Reviewed-by: mcimadamore
+
+diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/classfile/AccessFlags.java
+--- langtools/src/share/classes/com/sun/tools/classfile/AccessFlags.java Mon Aug 04 17:54:15 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/classfile/AccessFlags.java Fri Oct 25 06:07:26 2013 +0100
+@@ -58,7 +58,7 @@
+ public static final int ACC_ENUM = 0x4000; // class, inner, field
+ public static final int ACC_MODULE = 0x8000; // class, inner, field, method
+
+- private static enum Type { Class, InnerClass, Field, Method};
++ public static enum Kind { Class, InnerClass, Field, Method};
+
+ AccessFlags(ClassReader cr) throws IOException {
+ this(cr.readUnsignedShort());
+@@ -87,11 +87,11 @@
+
+ public Set<String> getClassModifiers() {
+ int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags);
+- return getModifiers(f, classModifiers, Type.Class);
++ return getModifiers(f, classModifiers, Kind.Class);
+ }
+
+ public Set<String> getClassFlags() {
+- return getFlags(classFlags, Type.Class);
++ return getFlags(classFlags, Kind.Class);
+ }
+
+ private static final int[] innerClassModifiers = {
+@@ -106,11 +106,11 @@
+
+ public Set<String> getInnerClassModifiers() {
+ int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags);
+- return getModifiers(f, innerClassModifiers, Type.InnerClass);
++ return getModifiers(f, innerClassModifiers, Kind.InnerClass);
+ }
+
+ public Set<String> getInnerClassFlags() {
+- return getFlags(innerClassFlags, Type.InnerClass);
++ return getFlags(innerClassFlags, Kind.InnerClass);
+ }
+
+ private static final int[] fieldModifiers = {
+@@ -124,11 +124,11 @@
+ };
+
+ public Set<String> getFieldModifiers() {
+- return getModifiers(fieldModifiers, Type.Field);
++ return getModifiers(fieldModifiers, Kind.Field);
+ }
+
+ public Set<String> getFieldFlags() {
+- return getFlags(fieldFlags, Type.Field);
++ return getFlags(fieldFlags, Kind.Field);
+ }
+
+ private static final int[] methodModifiers = {
+@@ -143,18 +143,18 @@
+ };
+
+ public Set<String> getMethodModifiers() {
+- return getModifiers(methodModifiers, Type.Method);
++ return getModifiers(methodModifiers, Kind.Method);
+ }
+
+ public Set<String> getMethodFlags() {
+- return getFlags(methodFlags, Type.Method);
++ return getFlags(methodFlags, Kind.Method);
+ }
+
+- private Set<String> getModifiers(int[] modifierFlags, Type t) {
++ private Set<String> getModifiers(int[] modifierFlags, Kind t) {
+ return getModifiers(flags, modifierFlags, t);
+ }
+
+- private static Set<String> getModifiers(int flags, int[] modifierFlags, Type t) {
++ private static Set<String> getModifiers(int flags, int[] modifierFlags, Kind t) {
+ Set<String> s = new LinkedHashSet<String>();
+ for (int m: modifierFlags) {
+ if ((flags & m) != 0)
+@@ -163,7 +163,7 @@
+ return s;
+ }
+
+- private Set<String> getFlags(int[] expectedFlags, Type t) {
++ private Set<String> getFlags(int[] expectedFlags, Kind t) {
+ Set<String> s = new LinkedHashSet<String>();
+ int f = flags;
+ for (int e: expectedFlags) {
+@@ -180,7 +180,7 @@
+ return s;
+ }
+
+- private static String flagToModifier(int flag, Type t) {
++ private static String flagToModifier(int flag, Kind t) {
+ switch (flag) {
+ case ACC_PUBLIC:
+ return "public";
+@@ -195,7 +195,7 @@
+ case ACC_SYNCHRONIZED:
+ return "synchronized";
+ case 0x80:
+- return (t == Type.Field ? "transient" : null);
++ return (t == Kind.Field ? "transient" : null);
+ case ACC_VOLATILE:
+ return "volatile";
+ case ACC_NATIVE:
+@@ -211,7 +211,7 @@
+ }
+ }
+
+- private static String flagToName(int flag, Type t) {
++ private static String flagToName(int flag, Kind t) {
+ switch (flag) {
+ case ACC_PUBLIC:
+ return "ACC_PUBLIC";
+@@ -224,11 +224,11 @@
+ case ACC_FINAL:
+ return "ACC_FINAL";
+ case 0x20:
+- return (t == Type.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED");
++ return (t == Kind.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED");
+ case 0x40:
+- return (t == Type.Field ? "ACC_VOLATILE" : "ACC_BRIDGE");
++ return (t == Kind.Field ? "ACC_VOLATILE" : "ACC_BRIDGE");
+ case 0x80:
+- return (t == Type.Field ? "ACC_TRANSIENT" : "ACC_VARARGS");
++ return (t == Kind.Field ? "ACC_TRANSIENT" : "ACC_VARARGS");
+ case ACC_NATIVE:
+ return "ACC_NATIVE";
+ case ACC_INTERFACE:
+@@ -250,5 +250,5 @@
+ }
+ }
+
+- final int flags;
++ public final int flags;
+ }
+diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/classfile/ConstantPool.java
+--- langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Mon Aug 04 17:54:15 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java Fri Oct 25 06:07:26 2013 +0100
+@@ -569,6 +569,11 @@
+ return visitor.visitNameAndType(this, data);
+ }
+
++ @Override
++ public String toString() {
++ return "CONSTANT_NameAndType_info[name_index: " + name_index + ", type_index: " + type_index + "]";
++ }
++
+ public final int name_index;
+ public final int type_index;
+ }
+@@ -596,6 +601,11 @@
+ return visitor.visitString(this, data);
+ }
+
++ @Override
++ public String toString() {
++ return "CONSTANT_String_info[class_index: " + string_index + "]";
++ }
++
+ public final int string_index;
+ }
+
+@@ -614,7 +624,19 @@
+
+ @Override
+ public String toString() {
+- return "CONSTANT_Utf8_info[value: " + value + "]";
++ if (value.length() < 32 && isPrintableAscii(value))
++ return "CONSTANT_Utf8_info[value: \"" + value + "\"]";
++ else
++ return "CONSTANT_Utf8_info[value: (" + value.length() + " chars)]";
++ }
++
++ static boolean isPrintableAscii(String s) {
++ for (int i = 0; i < s.length(); i++) {
++ char c = s.charAt(i);
++ if (c < 32 || c >= 127)
++ return false;
++ }
++ return true;
+ }
+
+ public <R, D> R accept(Visitor<R, D> visitor, D data) {
+diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/javap/AttributeWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Mon Aug 04 17:54:15 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Fri Oct 25 06:07:26 2013 +0100
+@@ -74,7 +74,7 @@
+ public class AttributeWriter extends BasicWriter
+ implements Attribute.Visitor<Void,Void>
+ {
+- static AttributeWriter instance(Context context) {
++ public static AttributeWriter instance(Context context) {
+ AttributeWriter instance = context.get(AttributeWriter.class);
+ if (instance == null)
+ instance = new AttributeWriter(context);
+diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/javap/ClassWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon Aug 04 17:54:15 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Fri Oct 25 06:07:26 2013 +0100
+@@ -93,17 +93,25 @@
+ this.lastModified = lastModified;
+ }
+
+- ClassFile getClassFile() {
++ protected ClassFile getClassFile() {
+ return classFile;
+ }
+
+- Method getMethod() {
++ protected void setClassFile(ClassFile cf) {
++ classFile = cf;
++ constant_pool = classFile.constant_pool;
++ }
++
++ protected Method getMethod() {
+ return method;
+ }
+
++ protected void setMethod(Method m) {
++ method = m;
++ }
++
+ public void write(ClassFile cf) {
+- classFile = cf;
+- constant_pool = classFile.constant_pool;
++ setClassFile(cf);
+
+ if ((options.sysInfo || options.verbose) && !options.compat) {
+ if (uri != null) {
+@@ -201,13 +209,13 @@
+ println();
+ }
+
+- void writeFields() {
++ protected void writeFields() {
+ for (Field f: classFile.fields) {
+ writeField(f);
+ }
+ }
+
+- void writeField(Field f) {
++ protected void writeField(Field f) {
+ if (!options.checkAccess(f.access_flags))
+ return;
+
+@@ -263,12 +271,12 @@
+ println();
+ }
+
+- void writeMethods() {
++ protected void writeMethods() {
+ for (Method m: classFile.methods)
+ writeMethod(m);
+ }
+
+- void writeMethod(Method m) {
++ protected void writeMethod(Method m) {
+ if (!options.checkAccess(m.access_flags))
+ return;
+
+diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/javap/ConstantWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Mon Aug 04 17:54:15 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Fri Oct 25 06:07:26 2013 +0100
+@@ -40,7 +40,7 @@
+ * deletion without notice.</b>
+ */
+ public class ConstantWriter extends BasicWriter {
+- static ConstantWriter instance(Context context) {
++ public static ConstantWriter instance(Context context) {
+ ConstantWriter instance = context.get(ConstantWriter.class);
+ if (instance == null)
+ instance = new ConstantWriter(context);
+@@ -54,7 +54,12 @@
+ options = Options.instance(context);
+ }
+
+- void writeConstantPool() {
++ protected void writeConstantPool() {
++ ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
++ writeConstantPool(constant_pool);
++ }
++
++ protected void writeConstantPool(ConstantPool constant_pool) {
+ ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() {
+ public Integer visitClass(CONSTANT_Class_info info, Void p) {
+ println("#" + info.name_index + ";\t// " + stringValue(info));
+@@ -114,7 +119,6 @@
+
+ };
+ println(" Constant pool:");
+- ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
+ int cpx = 1;
+ while (cpx < constant_pool.size()) {
+ try {
+@@ -127,7 +131,7 @@
+ }
+ }
+
+- void write(int cpx) {
++ protected void write(int cpx) {
+ ClassFile classFile = classWriter.getClassFile();
+ if (cpx == 0) {
+ print("#0");
+diff -r dca34170f5f8 -r a22d1b683f15 src/share/classes/com/sun/tools/javap/JavapTask.java
+--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Aug 04 17:54:15 2008 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Fri Oct 25 06:07:26 2013 +0100
+@@ -36,6 +36,7 @@
+ import java.io.Writer;
+ import java.security.DigestInputStream;
+ import java.security.MessageDigest;
++import java.security.NoSuchAlgorithmException;
+ import java.text.MessageFormat;
+ import java.util.ArrayList;
+ import java.util.Arrays;
+@@ -242,20 +243,27 @@
+
+ };
+
+- JavapTask() {
++ public JavapTask() {
+ context = new Context();
+ options = Options.instance(context);
++ attributeFactory = new Attribute.Factory();
+ }
+
+- JavapTask(Writer out,
++ public JavapTask(Writer out,
++ JavaFileManager fileManager,
++ DiagnosticListener<? super JavaFileObject> diagnosticListener) {
++ this();
++ this.log = getPrintWriterForWriter(out);
++ this.fileManager = fileManager;
++ this.diagnosticListener = diagnosticListener;
++ }
++
++ public JavapTask(Writer out,
+ JavaFileManager fileManager,
+ DiagnosticListener<? super JavaFileObject> diagnosticListener,
+ Iterable<String> options,
+ Iterable<String> classes) {
+- this();
+- this.log = getPrintWriterForWriter(out);
+- this.fileManager = fileManager;
+- this.diagnosticListener = diagnosticListener;
++ this(out, fileManager, diagnosticListener);
+
+ try {
+ handleOptions(options, false);
+@@ -464,29 +472,10 @@
+ continue;
+ }
+ }
+- Attribute.Factory attributeFactory = new Attribute.Factory();
+ attributeFactory.setCompat(options.compat);
+ attributeFactory.setJSR277(options.jsr277);
+
+- InputStream in = fo.openInputStream();
+- SizeInputStream sizeIn = null;
+- MessageDigest md = null;
+- if (options.sysInfo || options.verbose) {
+- md = MessageDigest.getInstance("MD5");
+- in = new DigestInputStream(in, md);
+- in = sizeIn = new SizeInputStream(in);
+- }
+-
+- ClassFile cf = ClassFile.read(in, attributeFactory);
+-
+- if (options.sysInfo || options.verbose) {
+- classWriter.setFile(fo.toUri());
+- classWriter.setLastModified(fo.getLastModified());
+- classWriter.setDigest("MD5", md.digest());
+- classWriter.setFileSize(sizeIn.size());
+- }
+-
+- classWriter.write(cf);
++ write(read(fo));
+
+ } catch (ConstantPoolException e) {
+ diagnosticListener.report(createDiagnostic("err.bad.constant.pool", className, e.getLocalizedMessage()));
+@@ -517,6 +506,103 @@
+ return ok;
+ }
+
++ public static class ClassFileInfo {
++ ClassFileInfo(JavaFileObject fo, ClassFile cf, byte[] digest, int size) {
++ this.fo = fo;
++ this.cf = cf;
++ this.digest = digest;
++ this.size = size;
++ }
++ public final JavaFileObject fo;
++ public final ClassFile cf;
++ public final byte[] digest;
++ public final int size;
++ }
++
++ public ClassFileInfo read(JavaFileObject fo) throws IOException, ConstantPoolException {
++ InputStream in = fo.openInputStream();
++ try {
++ SizeInputStream sizeIn = null;
++ MessageDigest md = null;
++ if (options.sysInfo || options.verbose) {
++ try {
++ md = MessageDigest.getInstance("MD5");
++ } catch (NoSuchAlgorithmException ignore) {
++ }
++ in = new DigestInputStream(in, md);
++ in = sizeIn = new SizeInputStream(in);
++ }
++
++ ClassFile cf = ClassFile.read(in, attributeFactory);
++ byte[] digest = (md == null) ? null : md.digest();
++ int size = (sizeIn == null) ? -1 : sizeIn.size();
++ return new ClassFileInfo(fo, cf, digest, size);
++ } finally {
++ in.close();
++ }
++ }
++
++ public void write(ClassFileInfo info) {
++ ClassWriter classWriter = ClassWriter.instance(context);
++ if (options.sysInfo || options.verbose) {
++ classWriter.setFile(info.fo.toUri());
++ classWriter.setLastModified(info.fo.getLastModified());
++ classWriter.setDigest("MD5", info.digest);
++ classWriter.setFileSize(info.size);
++ }
++
++ classWriter.write(info.cf);
++ }
++
++ protected void setClassFile(ClassFile classFile) {
++ ClassWriter classWriter = ClassWriter.instance(context);
++ classWriter.setClassFile(classFile);
++ }
++
++ protected void setMethod(Method enclosingMethod) {
++ ClassWriter classWriter = ClassWriter.instance(context);
++ classWriter.setMethod(enclosingMethod);
++ }
++
++ protected void write(Attribute value) {
++ AttributeWriter attrWriter = AttributeWriter.instance(context);
++ ClassWriter classWriter = ClassWriter.instance(context);
++ ClassFile cf = classWriter.getClassFile();
++ attrWriter.write(cf, value, cf.constant_pool);
++ }
++
++ protected void write(Attributes attrs) {
++ AttributeWriter attrWriter = AttributeWriter.instance(context);
++ ClassWriter classWriter = ClassWriter.instance(context);
++ ClassFile cf = classWriter.getClassFile();
++ attrWriter.write(cf, attrs, cf.constant_pool);
++ }
++
++ protected void write(ConstantPool constant_pool) {
++ ConstantWriter constantWriter = ConstantWriter.instance(context);
++ constantWriter.writeConstantPool(constant_pool);
++ }
++
++ protected void write(ConstantPool constant_pool, int value) {
++ ConstantWriter constantWriter = ConstantWriter.instance(context);
++ constantWriter.write(value);
++ }
++
++ protected void write(ConstantPool.CPInfo value) {
++ ConstantWriter constantWriter = ConstantWriter.instance(context);
++ constantWriter.println(value);
++ }
++
++ protected void write(Field value) {
++ ClassWriter classWriter = ClassWriter.instance(context);
++ classWriter.writeField(value);
++ }
++
++ protected void write(Method value) {
++ ClassWriter classWriter = ClassWriter.instance(context);
++ classWriter.writeMethod(value);
++ }
++
+ private JavaFileManager getDefaultFileManager(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) {
+ return JavapFileManager.create(dl, log, options);
+ }
+@@ -646,7 +732,7 @@
+ }
+ }
+
+- Context context;
++ protected Context context;
+ JavaFileManager fileManager;
+ PrintWriter log;
+ DiagnosticListener<? super JavaFileObject> diagnosticListener;
+@@ -655,6 +741,7 @@
+ //ResourceBundle bundle;
+ Locale task_locale;
+ Map<Locale, ResourceBundle> bundles;
++ protected Attribute.Factory attributeFactory;
+
+ private static final String progname = "javap";
+
diff --git a/java/openjdk6/files/icedtea/openjdk/6867671-javap_whitespace.patch b/java/openjdk6/files/icedtea/openjdk/6867671-javap_whitespace.patch
new file mode 100644
index 000000000000..2c5b0d72d658
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6867671-javap_whitespace.patch
@@ -0,0 +1,1041 @@
+# HG changeset patch
+# User jjg
+# Date 1382678228 -3600
+# Fri Oct 25 06:17:08 2013 +0100
+# Node ID db86275eb3f82caf87fbe6c162dc776cb5ed85dc
+# Parent a22d1b683f15e7f67d7d3de84f7c866a65c42552
+6867671: javap whitespace formatting issues
+Reviewed-by: mcimadamore
+
+diff -r a22d1b683f15 -r db86275eb3f8 src/share/classes/com/sun/tools/javap/AttributeWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Fri Oct 25 06:07:26 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java Fri Oct 25 06:17:08 2013 +0100
+@@ -41,7 +41,6 @@
+ import com.sun.tools.classfile.Deprecated_attribute;
+ import com.sun.tools.classfile.EnclosingMethod_attribute;
+ import com.sun.tools.classfile.Exceptions_attribute;
+-import com.sun.tools.classfile.Field;
+ import com.sun.tools.classfile.InnerClasses_attribute;
+ import com.sun.tools.classfile.LineNumberTable_attribute;
+ import com.sun.tools.classfile.LocalVariableTable_attribute;
+@@ -147,22 +146,26 @@
+ }
+
+ public Void visitAnnotationDefault(AnnotationDefault_attribute attr, Void ignore) {
+- println(" AnnotationDefault: ");
+- print(" default_value: ");
++ println("AnnotationDefault:");
++ indent(+1);
++ print("default_value: ");
+ annotationWriter.write(attr.default_value);
++ indent(-1);
+ return null;
+ }
+
+ public Void visitCharacterRangeTable(CharacterRangeTable_attribute attr, Void ignore) {
+- print(" CharacterRangeTable: ");
++ println("CharacterRangeTable:");
++ indent(+1);
+ for (int i = 0; i < attr.character_range_table.length; i++) {
+ CharacterRangeTable_attribute.Entry e = attr.character_range_table[i];
+ print(" " + e.start_pc + ", " +
+ e.end_pc + ", " +
+ Integer.toHexString(e.character_range_start) + ", " +
+ Integer.toHexString(e.character_range_end) + ", " +
+- Integer.toHexString(e.flags) +
+- "\t// ");
++ Integer.toHexString(e.flags));
++ tab();
++ print("// ");
+ print(e.start_pc + ", " +
+ e.end_pc + ", " +
+ (e.character_range_start >> 10) + ":" + (e.character_range_start & 0x3ff) + ", " +
+@@ -185,16 +188,13 @@
+ print(", branch-true");
+ if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_FALSE) != 0)
+ print(", branch-false");
+-
+-
+-
+ }
++ indent(-1);
+ return null;
+ }
+
+ public Void visitCode(Code_attribute attr, Void ignore) {
+ codeWriter.write(attr, constant_pool);
+- println();
+ return null;
+ }
+
+@@ -205,25 +205,23 @@
+
+ public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) {
+ if (options.compat) // BUG 6622216 javap names some attributes incorrectly
+- print(" Constant value: ");
++ print("Constant value: ");
+ else
+- print(" ConstantValue: ");
++ print("ConstantValue: ");
+ constantWriter.write(attr.constantvalue_index);
+- if (!options.compat) // BUG 6622232 javap gets whitespace confused
+- println();
++ println();
+ return null;
+ }
+
+ public Void visitDeprecated(Deprecated_attribute attr, Void ignore) {
+- if (!(options.compat && owner instanceof Field)) // BUG 6622232 javap gets whitespace confused
+- print(" ");
+ println("Deprecated: true");
+ return null;
+ }
+
+ public Void visitEnclosingMethod(EnclosingMethod_attribute attr, Void ignore) {
+- print(" EnclosingMethod: #" + attr.class_index + ".#" + attr.method_index
+- + "\t// " + getJavaClassName(attr));
++ print("EnclosingMethod: #" + attr.class_index + ".#" + attr.method_index);
++ tab();
++ print("// " + getJavaClassName(attr));
+ if (attr.method_index != 0)
+ print("." + getMethodName(attr));
+ println();
+@@ -247,15 +245,16 @@
+ }
+
+ public Void visitExceptions(Exceptions_attribute attr, Void ignore) {
+- println(" Exceptions: ");
+- print(" throws ");
++ println("Exceptions:");
++ indent(+1);
++ print("throws ");
+ for (int i = 0; i < attr.number_of_exceptions; i++) {
+ if (i > 0)
+ print(", ");
+ print(getJavaException(attr, i));
+ }
+- if (!options.compat) // BUG 6622232 javap gets whitespace confused
+- println();
++ println();
++ indent(-1);
+ return null;
+ }
+
+@@ -288,8 +287,7 @@
+ writeInnerClassHeader();
+ first = false;
+ }
+- if (!options.compat) // BUG 6622232: javap gets whitespace confused
+- print(" ");
++ print(" ");
+ for (String name: access_flags.getInnerClassModifiers())
+ print(name + " ");
+ if (info.inner_name_index!=0) {
+@@ -311,6 +309,8 @@
+ println();
+ }
+ }
++ if (!first)
++ indent(-1);
+ return null;
+ }
+
+@@ -323,26 +323,28 @@
+ }
+
+ private void writeInnerClassHeader() {
+- print(" ");
+ if (options.compat) // BUG 6622216: javap names some attributes incorrectly
+ print("InnerClass");
+ else
+ print("InnerClasses");
+ println(": ");
++ indent(+1);
+ }
+
+ public Void visitLineNumberTable(LineNumberTable_attribute attr, Void ignore) {
+- println(" LineNumberTable: ");
++ println("LineNumberTable:");
++ indent(+1);
+ for (LineNumberTable_attribute.Entry entry: attr.line_number_table) {
+- println(" line " + entry.line_number + ": " + entry.start_pc);
++ println("line " + entry.line_number + ": " + entry.start_pc);
+ }
++ indent(-1);
+ return null;
+ }
+
+ public Void visitLocalVariableTable(LocalVariableTable_attribute attr, Void ignore) {
+- println(" LocalVariableTable: ");
+- println(" Start Length Slot Name Signature");
+-
++ println("LocalVariableTable:");
++ indent(+1);
++ println("Start Length Slot Name Signature");
+ for (LocalVariableTable_attribute.Entry entry : attr.local_variable_table) {
+ Formatter formatter = new Formatter();
+ println(formatter.format("%8d %7d %5d %5s %s",
+@@ -350,25 +352,28 @@
+ constantWriter.stringValue(entry.name_index),
+ constantWriter.stringValue(entry.descriptor_index)));
+ }
++ indent(-1);
+ return null;
+ }
+
+ public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, Void ignore) {
+- println(" LocalVariableTypeTable: ");
+- println(" Start Length Slot Name Signature");
+-
++ println("LocalVariableTypeTable:");
++ indent(+1);
++ println("Start Length Slot Name Signature");
+ for (LocalVariableTypeTable_attribute.Entry entry : attr.local_variable_table) {
+- Formatter formatter = new Formatter();
+- println(formatter.format("%8d %7d %5d %5s %s",
++ println(String.format("%5d %7d %5d %5s %s",
+ entry.start_pc, entry.length, entry.index,
+ constantWriter.stringValue(entry.name_index),
+ constantWriter.stringValue(entry.signature_index)));
+ }
++ indent(-1);
+ return null;
+ }
+
+ public Void visitModule(Module_attribute attr, Void ignore) {
+- println(" Module: #" + attr.module_name + "\t// " + getModuleName(attr));
++ print("Module: #" + attr.module_name);
++ tab();
++ println("// " + getModuleName(attr));
+ return null;
+ }
+
+@@ -381,11 +386,15 @@
+ }
+
+ public Void visitModuleExportTable(ModuleExportTable_attribute attr, Void ignore) {
+- println(" ModuleExportTable:");
+- println(" Types: (" + attr.export_type_table.length + ")");
++ println("ModuleExportTable:");
++ indent(+1);
++ println("Types: (" + attr.export_type_table.length + ")");
+ for (int i = 0; i < attr.export_type_table.length; i++) {
+- println(" #" + attr.export_type_table[i] + "\t// " + getExportTypeName(attr, i));
++ print("#" + attr.export_type_table[i]);
++ tab();
++ println("// " + getExportTypeName(attr, i));
+ }
++ indent(-1);
+ return null;
+ }
+
+@@ -398,11 +407,15 @@
+ }
+
+ public Void visitModuleMemberTable(ModuleMemberTable_attribute attr, Void ignore) {
+- println(" ModuleMemberTable:");
+- println(" Packages: (" + attr.package_member_table.length + ")");
++ println("ModuleMemberTable:");
++ indent(+1);
++ println("Packages: (" + attr.package_member_table.length + ")");
+ for (int i = 0; i < attr.package_member_table.length; i++) {
+- println(" #" + attr.package_member_table[i] + "\t// " + getPackageMemberName(attr, i));
++ print("#" + attr.package_member_table[i]);
++ tab();
++ println("// " + getPackageMemberName(attr, i));
+ }
++ indent(-1);
+ return null;
+ }
+
+@@ -415,53 +428,67 @@
+ }
+
+ public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
+- println(" RuntimeVisibleAnnotations: ");
++ println("RuntimeVisibleAnnotations:");
++ indent(+1);
+ for (int i = 0; i < attr.annotations.length; i++) {
+- print(" " + i + ": ");
++ print(i + ": ");
+ annotationWriter.write(attr.annotations[i]);
+ println();
+ }
++ indent(-1);
+ return null;
+ }
+
+ public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, Void ignore) {
+- println(" RuntimeInvisibleAnnotations: ");
++ println("RuntimeInvisibleAnnotations:");
++ indent(+1);
+ for (int i = 0; i < attr.annotations.length; i++) {
+- print(" " + i + ": ");
++ print(i + ": ");
+ annotationWriter.write(attr.annotations[i]);
+ println();
+ }
++ indent(-1);
+ return null;
+ }
+
+ public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) {
+- println(" RuntimeVisibleParameterAnnotations: ");
++ println("RuntimeVisibleParameterAnnotations:");
++ indent(+1);
+ for (int param = 0; param < attr.parameter_annotations.length; param++) {
+- println(" parameter " + param + ": ");
++ println("parameter " + param + ": ");
++ indent(+1);
+ for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
+- print(" " + i + ": ");
++ print(i + ": ");
+ annotationWriter.write(attr.parameter_annotations[param][i]);
+ println();
+ }
++ indent(-1);
+ }
++ indent(-1);
+ return null;
+ }
+
+ public Void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, Void ignore) {
+- println(" RuntimeInvisibleParameterAnnotations: ");
++ println("RuntimeInvisibleParameterAnnotations:");
++ indent(+1);
+ for (int param = 0; param < attr.parameter_annotations.length; param++) {
+- println(" " + param + ": ");
++ println(param + ": ");
++ indent(+1);
+ for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
+- print(" " + i + ": ");
++ print(i + ": ");
+ annotationWriter.write(attr.parameter_annotations[param][i]);
+ println();
+ }
++ indent(-1);
+ }
++ indent(-1);
+ return null;
+ }
+
+ public Void visitSignature(Signature_attribute attr, Void ignore) {
+- println(" Signature: #" + attr.signature_index + "\t// " + getSignature(attr));
++ print("Signature: #" + attr.signature_index);
++ tab();
++ println("// " + getSignature(attr));
+ return null;
+ }
+
+@@ -474,12 +501,12 @@
+ }
+
+ public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) {
+- println(" SourceDebugExtension: " + attr.getValue());
++ println("SourceDebugExtension: " + attr.getValue());
+ return null;
+ }
+
+ public Void visitSourceFile(SourceFile_attribute attr, Void ignore) {
+- println(" SourceFile: \"" + getSourceFile(attr) + "\"");
++ println("SourceFile: \"" + getSourceFile(attr) + "\"");
+ return null;
+ }
+
+@@ -497,24 +524,26 @@
+ }
+
+ public Void visitStackMap(StackMap_attribute attr, Void ignore) {
+- println(" StackMap: number_of_entries = " + attr.number_of_entries);
+-
++ println("StackMap: number_of_entries = " + attr.number_of_entries);
++ indent(+1);
+ StackMapTableWriter w = new StackMapTableWriter();
+ for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
+ w.write(entry);
+ }
+ println();
++ indent(-1);
+ return null;
+ }
+
+ public Void visitStackMapTable(StackMapTable_attribute attr, Void ignore) {
+- println(" StackMapTable: number_of_entries = " + attr.number_of_entries);
+-
++ println("StackMapTable: number_of_entries = " + attr.number_of_entries);
++ indent(+1);
+ StackMapTableWriter w = new StackMapTableWriter();
+ for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
+ w.write(entry);
+ }
+ println();
++ indent(-1);
+ return null;
+ }
+
+@@ -533,29 +562,37 @@
+ public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) {
+ printHeader(frame);
+ println(" /* same_locals_1_stack_item */");
++ indent(+1);
+ printMap("stack", frame.stack);
++ indent(-1);
+ return null;
+ }
+
+ public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) {
+ printHeader(frame);
+ println(" /* same_locals_1_stack_item_frame_extended */");
+- println(" offset_delta = " + frame.offset_delta);
++ indent(+1);
++ println("offset_delta = " + frame.offset_delta);
+ printMap("stack", frame.stack);
++ indent(-1);
+ return null;
+ }
+
+ public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) {
+ printHeader(frame);
+ println(" /* chop */");
+- println(" offset_delta = " + frame.offset_delta);
++ indent(+1);
++ println("offset_delta = " + frame.offset_delta);
++ indent(-1);
+ return null;
+ }
+
+ public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) {
+ printHeader(frame);
+ println(" /* same_frame_extended */");
+- println(" offset_delta = " + frame.offset_delta);
++ indent(+1);
++ println("offset_delta = " + frame.offset_delta);
++ indent(-1);
+ return null;
+ }
+
+@@ -570,13 +607,16 @@
+ public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) {
+ printHeader(frame);
+ if (frame instanceof StackMap_attribute.stack_map_frame) {
+- println(" offset = " + frame.offset_delta);
++ indent(+1);
++ println(" offset = " + frame.offset_delta);
+ } else {
+ println(" /* full_frame */");
+- println(" offset_delta = " + frame.offset_delta);
++ indent(+1);
++ println("offset_delta = " + frame.offset_delta);
+ }
+ printMap("locals", frame.locals);
+ printMap("stack", frame.stack);
++ indent(-1);
+ return null;
+ }
+
+@@ -585,7 +625,7 @@
+ }
+
+ void printMap(String name, StackMapTable_attribute.verification_type_info[] map) {
+- print(" " + name + " = [");
++ print(name + " = [");
+ for (int i = 0; i < map.length; i++) {
+ StackMapTable_attribute.verification_type_info info = map[i];
+ int tag = info.tag;
+diff -r a22d1b683f15 -r db86275eb3f8 src/share/classes/com/sun/tools/javap/BasicWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/BasicWriter.java Fri Oct 25 06:07:26 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/BasicWriter.java Fri Oct 25 06:17:08 2013 +0100
+@@ -68,6 +68,18 @@
+ lineWriter.println();
+ }
+
++ protected void indent(int delta) {
++ lineWriter.indent(delta);
++ }
++
++ protected void tab() {
++ lineWriter.tab();
++ }
++
++ protected void setPendingNewline(boolean b) {
++ lineWriter.pendingNewline = b;
++ }
++
+ protected String report(AttributeException e) {
+ out.println("Error: " + e.getMessage()); // i18n?
+ return "???";
+@@ -101,19 +113,30 @@
+
+ protected LineWriter(Context context) {
+ context.put(LineWriter.class, this);
++ Options options = Options.instance(context);
++ indentWidth = options.indentWidth;
++ tabColumn = options.tabColumn;
+ out = context.get(PrintWriter.class);
+ buffer = new StringBuilder();
+ }
+
+ protected void print(String s) {
++ if (pendingNewline) {
++ println();
++ pendingNewline = false;
++ }
+ if (s == null)
+ s = "null";
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+- if (c == '\n') {
+- println();
+- } else {
+- buffer.append(c);
++ switch (c) {
++ case '\n':
++ println();
++ break;
++ default:
++ if (buffer.length() == 0)
++ indent();
++ buffer.append(c);
+ }
+ }
+
+@@ -124,8 +147,31 @@
+ buffer.setLength(0);
+ }
+
++ protected void indent(int delta) {
++ indentCount += delta;
++ }
++
++ protected void tab() {
++ if (buffer.length() == 0)
++ indent();
++ space(indentCount * indentWidth + tabColumn - buffer.length());
++ }
++
++ private void indent() {
++ space(indentCount * indentWidth);
++ }
++
++ private void space(int n) {
++ for (int i = 0; i < n; i++)
++ buffer.append(' ');
++ }
++
+ private PrintWriter out;
+ private StringBuilder buffer;
++ private int indentCount;
++ private int indentWidth;
++ private int tabColumn;
++ private boolean pendingNewline;
+ }
+ }
+
+diff -r a22d1b683f15 -r db86275eb3f8 src/share/classes/com/sun/tools/javap/ClassWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Fri Oct 25 06:07:26 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Fri Oct 25 06:17:08 2013 +0100
+@@ -120,6 +120,7 @@
+ else
+ println("Classfile " + uri);
+ }
++ indent(+1);
+ if (lastModified != -1) {
+ Date lm = new Date(lastModified);
+ DateFormat df = DateFormat.getDateInstance();
+@@ -144,6 +145,10 @@
+ println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\"");
+ }
+
++ if ((options.sysInfo || options.verbose) && !options.compat) {
++ indent(-1);
++ }
++
+ String name = getJavaName(classFile);
+ AccessFlags flags = cf.access_flags;
+
+@@ -190,23 +195,24 @@
+
+ if (options.verbose) {
+ println();
++ indent(+1);
+ attrWriter.write(cf, cf.attributes, constant_pool);
+- println(" minor version: " + cf.minor_version);
+- println(" major version: " + cf.major_version);
++ println("minor version: " + cf.minor_version);
++ println("major version: " + cf.major_version);
+ if (!options.compat)
+- writeList(" flags: ", flags.getClassFlags(), NEWLINE);
++ writeList("flags: ", flags.getClassFlags(), NEWLINE);
++ indent(-1);
+ constantWriter.writeConstantPool();
+- println();
+ } else {
+- if (!options.compat)
+- print(" ");
++ print(" ");
+ }
+
+ println("{");
++ indent(+1);
+ writeFields();
+ writeMethods();
++ indent(-1);
+ println("}");
+- println();
+ }
+
+ protected void writeFields() {
+@@ -219,14 +225,6 @@
+ if (!options.checkAccess(f.access_flags))
+ return;
+
+- if (!(options.showLineAndLocalVariableTables
+- || options.showDisassembled
+- || options.verbose
+- || options.showInternalSignatures
+- || options.showAllAttrs)) {
+- print(" ");
+- }
+-
+ AccessFlags flags = f.access_flags;
+ writeModifiers(flags.getFieldModifiers());
+ Signature_attribute sigAttr = getSignature(f.attributes);
+@@ -255,11 +253,13 @@
+ print(";");
+ println();
+
++ indent(+1);
++
+ if (options.showInternalSignatures)
+- println(" Signature: " + getValue(f.descriptor));
++ println("Signature: " + getValue(f.descriptor));
+
+ if (options.verbose && !options.compat)
+- writeList(" flags: ", flags.getFieldFlags(), NEWLINE);
++ writeList("flags: ", flags.getFieldFlags(), NEWLINE);
+
+ if (options.showAllAttrs) {
+ for (Attribute attr: f.attributes)
+@@ -267,6 +267,8 @@
+ println();
+ }
+
++ indent(-1);
++
+ if (options.showDisassembled || options.showLineAndLocalVariableTables)
+ println();
+ }
+@@ -274,6 +276,7 @@
+ protected void writeMethods() {
+ for (Method m: classFile.methods)
+ writeMethod(m);
++ setPendingNewline(false);
+ }
+
+ protected void writeMethod(Method m) {
+@@ -282,14 +285,6 @@
+
+ method = m;
+
+- if (!(options.showLineAndLocalVariableTables
+- || options.showDisassembled
+- || options.verbose
+- || options.showInternalSignatures
+- || options.showAllAttrs)) {
+- print(" ");
+- }
+-
+ AccessFlags flags = m.access_flags;
+
+ Descriptor d;
+@@ -337,16 +332,6 @@
+ if (e_attr != null) { // if there are generic exceptions, there must be erased exceptions
+ if (e_attr instanceof Exceptions_attribute) {
+ Exceptions_attribute exceptions = (Exceptions_attribute) e_attr;
+- if (options.compat) { // Bug XXXXXXX whitespace
+- if (!(options.showLineAndLocalVariableTables
+- || options.showDisassembled
+- || options.verbose
+- || options.showInternalSignatures
+- || options.showAllAttrs)) {
+- print(" ");
+- }
+- print(" ");
+- }
+ print(" throws ");
+ if (methodExceptions != null) { // use generic list if available
+ writeList("", methodExceptions, "");
+@@ -362,14 +347,17 @@
+ }
+ }
+
+- print(";");
+- println();
++ println(";");
+
+- if (options.showInternalSignatures)
+- println(" Signature: " + getValue(m.descriptor));
++ indent(+1);
+
+- if (options.verbose && !options.compat)
+- writeList(" flags: ", flags.getMethodFlags(), NEWLINE);
++ if (options.showInternalSignatures) {
++ println("Signature: " + getValue(m.descriptor));
++ }
++
++ if (options.verbose && !options.compat) {
++ writeList("flags: ", flags.getMethodFlags(), NEWLINE);
++ }
+
+ Code_attribute code = null;
+ Attribute c_attr = m.attributes.get(Attribute.Code);
+@@ -382,33 +370,35 @@
+
+ if (options.showDisassembled && !options.showAllAttrs) {
+ if (code != null) {
+- println(" Code:");
++ println("Code:");
+ codeWriter.writeInstrs(code);
+ codeWriter.writeExceptionTable(code);
+ }
+- println();
+ }
+
+ if (options.showLineAndLocalVariableTables) {
+- if (code != null)
++ if (code != null) {
+ attrWriter.write(code, code.attributes.get(Attribute.LineNumberTable), constant_pool);
+- println();
+- if (code != null)
+ attrWriter.write(code, code.attributes.get(Attribute.LocalVariableTable), constant_pool);
+- println();
+- println();
++ }
+ }
+
+ if (options.showAllAttrs) {
+ Attribute[] attrs = m.attributes.attrs;
+ for (Attribute attr: attrs)
+ attrWriter.write(m, attr, constant_pool);
++ }
+
+-// // the following condition is to mimic old javap
+-// if (!(attrs.length > 0 &&
+-// attrs[attrs.length - 1] instanceof Exceptions_attribute))
+- println();
+- }
++ indent(-1);
++
++ // set pendingNewline to write a newline before the next method (if any)
++ // if a separator is desired
++ setPendingNewline(
++ options.showDisassembled ||
++ options.showAllAttrs ||
++ options.showInternalSignatures ||
++ options.showLineAndLocalVariableTables ||
++ options.verbose);
+ }
+
+ void writeModifiers(Collection<String> items) {
+diff -r a22d1b683f15 -r db86275eb3f8 src/share/classes/com/sun/tools/javap/CodeWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Fri Oct 25 06:07:26 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Fri Oct 25 06:17:08 2013 +0100
+@@ -62,11 +62,13 @@
+ }
+
+ void write(Code_attribute attr, ConstantPool constant_pool) {
+- println(" Code:");
++ println("Code:");
++ indent(+1);
+ writeVerboseHeader(attr, constant_pool);
+ writeInstrs(attr);
+ writeExceptionTable(attr);
+ attrWriter.write(attr, attr.attributes, constant_pool);
++ indent(-1);
+ }
+
+ public void writeVerboseHeader(Code_attribute attr, ConstantPool constant_pool) {
+@@ -83,9 +85,9 @@
+ argCount = report(e);
+ }
+
+- println(" Stack=" + attr.max_stack +
+- ", Locals=" + attr.max_locals +
+- ", Args_size=" + argCount);
++ println("stack=" + attr.max_stack +
++ ", locals=" + attr.max_locals +
++ ", args_size=" + argCount);
+
+ }
+
+@@ -101,8 +103,7 @@
+ }
+
+ public void writeInstr(Instruction instr) {
+- print(" " + instr.getPC() + ":\t");
+- print(instr.getMnemonic());
++ print(String.format("%4d: %-12s ", instr.getPC(), instr.getMnemonic()));
+ instr.accept(instructionPrinter, null);
+ println();
+ }
+@@ -120,54 +121,62 @@
+ }
+
+ public Void visitBranch(Instruction instr, int offset, Void p) {
+- print("\t" + (instr.getPC() + offset));
++ print((instr.getPC() + offset));
+ return null;
+ }
+
+ public Void visitConstantPoolRef(Instruction instr, int index, Void p) {
+- print("\t#" + index + "; //");
++ print("#" + index + ";");
++ tab();
++ print("// ");
+ printConstant(index);
+ return null;
+ }
+
+ public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Void p) {
+- print("\t#" + index + ", " + value + "; //");
++ print("#" + index + ", " + value + ";");
++ tab();
++ print("// ");
+ printConstant(index);
+ return null;
+ }
+
+ public Void visitLocal(Instruction instr, int index, Void p) {
+- print("\t" + index);
++ print(index);
+ return null;
+ }
+
+ public Void visitLocalAndValue(Instruction instr, int index, int value, Void p) {
+- print("\t" + index + ", " + value);
++ print(index + ", " + value);
+ return null;
+ }
+
+ public Void visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets) {
+ int pc = instr.getPC();
+- print("{ //" + npairs);
++ print("{ // " + npairs);
++ indent(+1);
+ for (int i = 0; i < npairs; i++) {
+- print("\n\t\t" + matches[i] + ": " + (pc + offsets[i]) + ";");
++ print("\n" + matches[i] + ": " + (pc + offsets[i]) + ";");
+ }
+- print("\n\t\tdefault: " + (pc + default_) + " }");
++ print("\ndefault: " + (pc + default_) + " }");
++ indent(-1);
+ return null;
+ }
+
+ public Void visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets) {
+ int pc = instr.getPC();
+ print("{ //" + low + " to " + high);
++ indent(+1);
+ for (int i = 0; i < offsets.length; i++) {
+- print("\n\t\t" + (low + i) + ": " + (pc + offsets[i]) + ";");
++ print("\n" + (low + i) + ": " + (pc + offsets[i]) + ";");
+ }
+- print("\n\t\tdefault: " + (pc + default_) + " }");
++ print("\ndefault: " + (pc + default_) + " }");
++ indent(-1);
+ return null;
+ }
+
+ public Void visitValue(Instruction instr, int value, Void p) {
+- print("\t" + value);
++ print(value);
+ return null;
+ }
+
+@@ -179,13 +188,13 @@
+
+ public void writeExceptionTable(Code_attribute attr) {
+ if (attr.exception_table_langth > 0) {
+- println(" Exception table:");
+- println(" from to target type");
++ println("Exception table:");
++ indent(+1);
++ println(" from to target type");
+ for (int i = 0; i < attr.exception_table.length; i++) {
+ Code_attribute.Exception_data handler = attr.exception_table[i];
+- printFixedWidthInt(handler.start_pc, 6);
+- printFixedWidthInt(handler.end_pc, 6);
+- printFixedWidthInt(handler.handler_pc, 6);
++ print(String.format(" %5d %5d %5d",
++ handler.start_pc, handler.end_pc, handler.handler_pc));
+ print(" ");
+ int catch_type = handler.catch_type;
+ if (catch_type == 0) {
+@@ -193,9 +202,9 @@
+ } else {
+ print("Class ");
+ println(constantWriter.stringValue(catch_type));
+- println("");
+ }
+ }
++ indent(-1);
+ }
+
+ }
+@@ -204,13 +213,6 @@
+ constantWriter.write(index);
+ }
+
+- private void printFixedWidthInt(int n, int width) {
+- String s = String.valueOf(n);
+- for (int i = s.length(); i < width; i++)
+- print(" ");
+- print(s);
+- }
+-
+ private static int align(int n) {
+ return (n + 3) & ~3;
+ }
+diff -r a22d1b683f15 -r db86275eb3f8 src/share/classes/com/sun/tools/javap/ConstantWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Fri Oct 25 06:07:26 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Fri Oct 25 06:17:08 2013 +0100
+@@ -62,7 +62,9 @@
+ protected void writeConstantPool(ConstantPool constant_pool) {
+ ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() {
+ public Integer visitClass(CONSTANT_Class_info info, Void p) {
+- println("#" + info.name_index + ";\t// " + stringValue(info));
++ print("#" + info.name_index + ";");
++ tab();
++ println("// " + stringValue(info));
+ return 1;
+ }
+
+@@ -72,7 +74,9 @@
+ }
+
+ public Integer visitFieldref(CONSTANT_Fieldref_info info, Void p) {
+- println("#" + info.class_index + ".#" + info.name_and_type_index + ";\t// " + stringValue(info));
++ print("#" + info.class_index + ".#" + info.name_and_type_index + ";");
++ tab();
++ println("// " + stringValue(info));
+ return 1;
+ }
+
+@@ -87,7 +91,9 @@
+ }
+
+ public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) {
+- println("#" + info.class_index + ".#" + info.name_and_type_index + ";\t// " + stringValue(info));
++ print("#" + info.class_index + ".#" + info.name_and_type_index + ";");
++ tab();
++ println("// " + stringValue(info));
+ return 1;
+ }
+
+@@ -97,18 +103,23 @@
+ }
+
+ public Integer visitNameAndType(CONSTANT_NameAndType_info info, Void p) {
+- String tab = (options.compat ? "" : "\t"); // BUG 6622232 javap gets whitespace confused
+- println("#" + info.name_index + ":#" + info.type_index + ";" + tab + "// " + stringValue(info));
++ print("#" + info.name_index + ":#" + info.type_index + ";");
++ tab();
++ println("// " + stringValue(info));
+ return 1;
+ }
+
+ public Integer visitMethodref(CONSTANT_Methodref_info info, Void p) {
+- println("#" + info.class_index + ".#" + info.name_and_type_index + ";\t// " + stringValue(info));
++ print("#" + info.class_index + ".#" + info.name_and_type_index + ";");
++ tab();
++ println("// " + stringValue(info));
+ return 1;
+ }
+
+ public Integer visitString(CONSTANT_String_info info, Void p) {
+- println("#" + info.string_index + ";\t// " + stringValue(info));
++ print("#" + info.string_index + ";");
++ tab();
++ println("// " + stringValue(info));
+ return 1;
+ }
+
+@@ -118,17 +129,21 @@
+ }
+
+ };
+- println(" Constant pool:");
++ println("Constant pool:");
++ indent(+1);
++ int width = String.valueOf(constant_pool.size()).length() + 1;
+ int cpx = 1;
+ while (cpx < constant_pool.size()) {
++ print(String.format("const %" + width + "s", ("#" + cpx)));
+ try {
+ CPInfo cpInfo = constant_pool.get(cpx);
+- print("const #" + cpx + " = " + tagName(cpInfo.getTag()) + "\t");
++ print(String.format(" = %-15s ", tagName(cpInfo.getTag())));
+ cpx += cpInfo.accept(v, null);
+ } catch (ConstantPool.InvalidIndex ex) {
+- print("const #" + cpx); // should not happen
++ // should not happen
+ }
+ }
++ indent(-1);
+ }
+
+ protected void write(int cpx) {
+diff -r a22d1b683f15 -r db86275eb3f8 src/share/classes/com/sun/tools/javap/JavapTask.java
+--- langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Fri Oct 25 06:07:26 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Fri Oct 25 06:17:08 2013 +0100
+@@ -239,6 +239,38 @@
+ void process(JavapTask task, String opt, String arg) {
+ task.options.showConstants = true;
+ }
++ },
++
++ new Option(false, "-XDindent:") {
++ @Override
++ boolean matches(String opt) {
++ int sep = opt.indexOf(":");
++ return sep != -1 && super.matches(opt.substring(0, sep + 1));
++ }
++
++ void process(JavapTask task, String opt, String arg) throws BadArgs {
++ int sep = opt.indexOf(":");
++ try {
++ task.options.indentWidth = Integer.valueOf(opt.substring(sep + 1));
++ } catch (NumberFormatException e) {
++ }
++ }
++ },
++
++ new Option(false, "-XDtab:") {
++ @Override
++ boolean matches(String opt) {
++ int sep = opt.indexOf(":");
++ return sep != -1 && super.matches(opt.substring(0, sep + 1));
++ }
++
++ void process(JavapTask task, String opt, String arg) throws BadArgs {
++ int sep = opt.indexOf(":");
++ try {
++ task.options.tabColumn = Integer.valueOf(opt.substring(sep + 1));
++ } catch (NumberFormatException e) {
++ }
++ }
+ }
+
+ };
+diff -r a22d1b683f15 -r db86275eb3f8 src/share/classes/com/sun/tools/javap/Options.java
+--- langtools/src/share/classes/com/sun/tools/javap/Options.java Fri Oct 25 06:07:26 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/Options.java Fri Oct 25 06:17:08 2013 +0100
+@@ -79,6 +79,8 @@
+ public boolean showAllAttrs;
+ public boolean showConstants;
+ public boolean sysInfo;
++ public int indentWidth = 2; // #spaces per indentWidth level
++ public int tabColumn = 40; // column number for comments
+
+ public boolean compat; // bug-for-bug compatibility mode with old javap
+ public boolean jsr277;
diff --git a/java/openjdk6/files/icedtea/openjdk/6868539-constant_pool_tags.patch b/java/openjdk6/files/icedtea/openjdk/6868539-constant_pool_tags.patch
new file mode 100644
index 000000000000..f70e8ef53609
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6868539-constant_pool_tags.patch
@@ -0,0 +1,163 @@
+# HG changeset patch
+# User jjg
+# Date 1249779397 25200
+# Sat Aug 08 17:56:37 2009 -0700
+# Node ID 4f38abed863c89ee101a3af495e7293df04a4a0e
+# Parent db86275eb3f82caf87fbe6c162dc776cb5ed85dc
+6868539: javap should use current names for constant pool tags
+Reviewed-by: ksrini
+
+diff -r db86275eb3f8 -r 4f38abed863c src/share/classes/com/sun/tools/javap/CodeWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Fri Oct 25 06:17:08 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Sat Aug 08 17:56:37 2009 -0700
+@@ -103,7 +103,7 @@
+ }
+
+ public void writeInstr(Instruction instr) {
+- print(String.format("%4d: %-12s ", instr.getPC(), instr.getMnemonic()));
++ print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
+ instr.accept(instructionPrinter, null);
+ println();
+ }
+diff -r db86275eb3f8 -r 4f38abed863c src/share/classes/com/sun/tools/javap/ConstantWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Fri Oct 25 06:17:08 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java Sat Aug 08 17:56:37 2009 -0700
+@@ -134,10 +134,10 @@
+ int width = String.valueOf(constant_pool.size()).length() + 1;
+ int cpx = 1;
+ while (cpx < constant_pool.size()) {
+- print(String.format("const %" + width + "s", ("#" + cpx)));
++ print(String.format("%" + width + "s", ("#" + cpx)));
+ try {
+ CPInfo cpInfo = constant_pool.get(cpx);
+- print(String.format(" = %-15s ", tagName(cpInfo.getTag())));
++ print(String.format(" = %-18s ", cpTagName(cpInfo)));
+ cpx += cpInfo.accept(v, null);
+ } catch (ConstantPool.InvalidIndex ex) {
+ // should not happen
+@@ -178,10 +178,15 @@
+ print(tagName(tag) + " " + stringValue(cpInfo));
+ }
+
++ String cpTagName(CPInfo cpInfo) {
++ String n = cpInfo.getClass().getSimpleName();
++ return n.replace("CONSTANT_", "").replace("_info", "");
++ }
++
+ String tagName(int tag) {
+ switch (tag) {
+ case CONSTANT_Utf8:
+- return "Asciz";
++ return "Utf8";
+ case CONSTANT_Integer:
+ return "int";
+ case CONSTANT_Float:
+@@ -203,7 +208,7 @@
+ case CONSTANT_NameAndType:
+ return "NameAndType";
+ default:
+- return "unknown tag";
++ return "(unknown tag)";
+ }
+ }
+
+diff -r db86275eb3f8 -r 4f38abed863c test/tools/javap/T6868539.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ langtools/test/tools/javap/T6868539.java Sat Aug 08 17:56:37 2009 -0700
+@@ -0,0 +1,96 @@
++/*
++ * 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 6868539 6868548
++ * @summary javap should use current names for constant pool entries,
++ * remove spurious ';' from constant pool entries
++ */
++
++import java.io.*;
++import java.util.*;
++
++public class T6868539
++
++{
++ public static void main(String... args) {
++ new T6868539().run();
++ }
++
++ void run() {
++ verify("T6868539", "Utf8 +java/lang/String"); // 1: Utf8
++ // 2: currently unused
++ verify("T6868539", "Integer +123456"); // 3: Integer
++ verify("T6868539", "Float +123456.0f"); // 4: Float
++ verify("T6868539", "Long +123456l"); // 5: Long
++ verify("T6868539", "Double +123456.0d"); // 6: Double
++ verify("T6868539", "Class +#[0-9]+ +// + T6868539"); // 7: Class
++ verify("T6868539", "String +#[0-9]+ +// + not found"); // 8: String
++ verify("T6868539", "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I"); // 9: Fieldref
++ verify("T6868539", "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V"); // 10: Methodref
++ verify("T6868539", "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
++ // 11: InterfaceMethodref
++ verify("T6868539", "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V"); // 12: NameAndType
++ if (errors > 0)
++ throw new Error(errors + " found.");
++ }
++
++ void verify(String className, String... expects) {
++ String output = javap(className);
++ for (String expect: expects) {
++ if (!output.matches("(?s).*" + expect + ".*"))
++ error(expect + " not found");
++ }
++ }
++
++ void error(String msg) {
++ System.err.println(msg);
++ errors++;
++ }
++
++ int errors;
++
++ String javap(String className) {
++ String testClasses = System.getProperty("test.classes", ".");
++ StringWriter sw = new StringWriter();
++ PrintWriter out = new PrintWriter(sw);
++ String[] args = { "-v", "-classpath", testClasses, className };
++ int rc = com.sun.tools.javap.Main.run(args, out);
++ if (rc != 0)
++ throw new Error("javap failed. rc=" + rc);
++ out.close();
++ String output = sw.toString();
++ System.out.println("class " + className);
++ System.out.println(output);
++ return output;
++ }
++
++ int i = 123456;
++ float f = 123456.f;
++ double d = 123456.;
++ long l = 123456L;
++
++ void m(Runnable r) { r.run(); }
++}
++
diff --git a/java/openjdk6/files/icedtea/openjdk/6902264-fix_indentation.patch b/java/openjdk6/files/icedtea/openjdk/6902264-fix_indentation.patch
new file mode 100644
index 000000000000..9cd7541a1d04
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6902264-fix_indentation.patch
@@ -0,0 +1,159 @@
+# HG changeset patch
+# User jjg
+# Date 1382713809 -3600
+# Fri Oct 25 16:10:09 2013 +0100
+# Node ID 9083313d5733ca9be66bc52cf64b9b5d4dd2e39a
+# Parent a7567fdabf3eae2c495726e6c25e2364e175261f
+6902264: fix indentation of tableswitch and lookupswitch
+Reviewed-by: ksrini
+
+diff -r a7567fdabf3e -r 9083313d5733 src/share/classes/com/sun/tools/classfile/Instruction.java
+--- langtools/src/share/classes/com/sun/tools/classfile/Instruction.java Tue May 19 13:53:00 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/classfile/Instruction.java Fri Oct 25 16:10:09 2013 +0100
+@@ -106,9 +106,9 @@
+ /** See {@link Kind#LOCAL_UBYTE}. */
+ R visitLocalAndValue(Instruction instr, int index, int value, P p);
+ /** See {@link Kind#DYNAMIC}. */
+- R visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets);
++ R visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, P p);
+ /** See {@link Kind#DYNAMIC}. */
+- R visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets);
++ R visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, P p);
+ /** See {@link Kind#BYTE}, {@link Kind#SHORT}. */
+ R visitValue(Instruction instr, int value, P p);
+ /** Instruction is unrecognized. */
+@@ -282,7 +282,7 @@
+ for (int i = 0; i < values.length; i++)
+ values[i] = getInt(pad + 12 + 4 * i);
+ return visitor.visitTableSwitch(
+- this, default_, low, high, values);
++ this, default_, low, high, values, p);
+ }
+ case LOOKUPSWITCH: {
+ int pad = align(pc + 1) - pc;
+@@ -295,7 +295,7 @@
+ offsets[i] = getInt(pad + 12 + i * 8);
+ }
+ return visitor.visitLookupSwitch(
+- this, default_, npairs, matches, offsets);
++ this, default_, npairs, matches, offsets, p);
+ }
+ default:
+ throw new IllegalStateException();
+diff -r a7567fdabf3e -r 9083313d5733 src/share/classes/com/sun/tools/javap/CodeWriter.java
+--- langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Tue May 19 13:53:00 2009 -0700
++++ langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java Fri Oct 25 16:10:09 2013 +0100
+@@ -117,28 +117,33 @@
+
+ public void writeInstr(Instruction instr) {
+ print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
+- instr.accept(instructionPrinter, null);
++ // compute the number of indentations for the body of multi-line instructions
++ // This is 6 (the width of "%4d: "), divided by the width of each indentation level,
++ // and rounded up to the next integer.
++ int indentWidth = options.indentWidth;
++ int indent = (6 + indentWidth - 1) / indentWidth;
++ instr.accept(instructionPrinter, indent);
+ println();
+ }
+ // where
+- Instruction.KindVisitor<Void,Void> instructionPrinter =
+- new Instruction.KindVisitor<Void,Void>() {
++ Instruction.KindVisitor<Void,Integer> instructionPrinter =
++ new Instruction.KindVisitor<Void,Integer>() {
+
+- public Void visitNoOperands(Instruction instr, Void p) {
++ public Void visitNoOperands(Instruction instr, Integer indent) {
+ return null;
+ }
+
+- public Void visitArrayType(Instruction instr, TypeKind kind, Void p) {
++ public Void visitArrayType(Instruction instr, TypeKind kind, Integer indent) {
+ print(" " + kind.name);
+ return null;
+ }
+
+- public Void visitBranch(Instruction instr, int offset, Void p) {
++ public Void visitBranch(Instruction instr, int offset, Integer indent) {
+ print((instr.getPC() + offset));
+ return null;
+ }
+
+- public Void visitConstantPoolRef(Instruction instr, int index, Void p) {
++ public Void visitConstantPoolRef(Instruction instr, int index, Integer indent) {
+ print("#" + index + ";");
+ tab();
+ print("// ");
+@@ -146,7 +151,7 @@
+ return null;
+ }
+
+- public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Void p) {
++ public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Integer indent) {
+ print("#" + index + ", " + value + ";");
+ tab();
+ print("// ");
+@@ -154,46 +159,48 @@
+ return null;
+ }
+
+- public Void visitLocal(Instruction instr, int index, Void p) {
++ public Void visitLocal(Instruction instr, int index, Integer indent) {
+ print(index);
+ return null;
+ }
+
+- public Void visitLocalAndValue(Instruction instr, int index, int value, Void p) {
++ public Void visitLocalAndValue(Instruction instr, int index, int value, Integer indent) {
+ print(index + ", " + value);
+ return null;
+ }
+
+- public Void visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets) {
++ public Void visitLookupSwitch(Instruction instr,
++ int default_, int npairs, int[] matches, int[] offsets, Integer indent) {
+ int pc = instr.getPC();
+ print("{ // " + npairs);
+- indent(+1);
++ indent(indent);
+ for (int i = 0; i < npairs; i++) {
+- print("\n" + matches[i] + ": " + (pc + offsets[i]) + ";");
++ print(String.format("%n%12d: %d", matches[i], (pc + offsets[i])));
+ }
+- print("\ndefault: " + (pc + default_) + " }");
+- indent(-1);
++ print("\n default: " + (pc + default_) + "\n}");
++ indent(-indent);
+ return null;
+ }
+
+- public Void visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets) {
++ public Void visitTableSwitch(Instruction instr,
++ int default_, int low, int high, int[] offsets, Integer indent) {
+ int pc = instr.getPC();
+- print("{ //" + low + " to " + high);
+- indent(+1);
++ print("{ // " + low + " to " + high);
++ indent(indent);
+ for (int i = 0; i < offsets.length; i++) {
+- print("\n" + (low + i) + ": " + (pc + offsets[i]) + ";");
++ print(String.format("%n%12d: %d", (low + i), (pc + offsets[i])));
+ }
+- print("\ndefault: " + (pc + default_) + " }");
+- indent(-1);
++ print("\n default: " + (pc + default_) + "\n}");
++ indent(-indent);
+ return null;
+ }
+
+- public Void visitValue(Instruction instr, int value, Void p) {
++ public Void visitValue(Instruction instr, int value, Integer indent) {
+ print(value);
+ return null;
+ }
+
+- public Void visitUnknown(Instruction instr, Void p) {
++ public Void visitUnknown(Instruction instr, Integer indent) {
+ return null;
+ }
+ };
diff --git a/java/openjdk6/files/icedtea/openjdk/6954275-big_xml_signatures.patch b/java/openjdk6/files/icedtea/openjdk/6954275-big_xml_signatures.patch
new file mode 100644
index 000000000000..24420ccfb189
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/6954275-big_xml_signatures.patch
@@ -0,0 +1,194 @@
+# HG changeset patch
+# User mullan
+# Date 1287154559 14400
+# Fri Oct 15 10:55:59 2010 -0400
+# Node ID 5e3c766d18092d498d9019827c1058a32f1c4e2a
+# Parent e5a4a4ec7b21f3d092d0b29024ff903864d05543
+6954275: XML signatures with reference data larger 16KB and cacheRef on fails to validate
+Reviewed-by: xuelei
+
+diff -r e5a4a4ec7b21 -r 5e3c766d1809 src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
+--- jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Mon Oct 28 21:46:43 2013 +0000
++++ jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Fri Oct 15 10:55:59 2010 -0400
+@@ -3,7 +3,7 @@
+ * DO NOT REMOVE OR ALTER!
+ */
+ /*
+- * Copyright 1999-2005 The Apache Software Foundation.
++ * Copyright 1999-2010 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.
+@@ -23,66 +23,70 @@
+ import java.io.OutputStream;
+
+ /**
+- * A simple Unsynced ByteArryOutputStream
++ * A simple Unsynced ByteArrayOutputStream
+ * @author raul
+ *
+ */
+ public class UnsyncByteArrayOutputStream extends OutputStream {
+- private static ThreadLocal bufCahce = new ThreadLocal() {
++ private static final int INITIAL_SIZE = 8192;
++ private static ThreadLocal bufCache = new ThreadLocal() {
+ protected synchronized Object initialValue() {
+- return new byte[8*1024];
++ return new byte[INITIAL_SIZE];
+ }
+ };
+- byte[] buf;
+- int size=8*1024;//buf.length;
+- int pos=0;
+- public UnsyncByteArrayOutputStream() {
+- buf=(byte[])bufCahce.get();
++
++ private byte[] buf;
++ private int size = INITIAL_SIZE;
++ private int pos = 0;
++
++ public UnsyncByteArrayOutputStream() {
++ buf = (byte[])bufCache.get();
++ }
++
++ public void write(byte[] arg0) {
++ int newPos = pos + arg0.length;
++ if (newPos > size) {
++ expandSize(newPos);
+ }
+- /** @inheritDoc */
+- public void write(byte[] arg0) {
+- int newPos=pos+arg0.length;
+- if (newPos>size) {
+- expandSize();
+- }
+- System.arraycopy(arg0,0,buf,pos,arg0.length);
+- pos=newPos;
++ System.arraycopy(arg0, 0, buf, pos, arg0.length);
++ pos = newPos;
++ }
++
++ public void write(byte[] arg0, int arg1, int arg2) {
++ int newPos = pos + arg2;
++ if (newPos > size) {
++ expandSize(newPos);
+ }
+- /** @inheritDoc */
+- public void write(byte[] arg0, int arg1, int arg2) {
+- int newPos=pos+arg2;
+- if (newPos>size) {
+- expandSize();
+- }
+- System.arraycopy(arg0,arg1,buf,pos,arg2);
+- pos=newPos;
++ System.arraycopy(arg0, arg1, buf, pos, arg2);
++ pos = newPos;
++ }
++
++ public void write(int arg0) {
++ int newPos = pos + 1;
++ if (newPos > size) {
++ expandSize(newPos);
+ }
+- /** @inheritDoc */
+- public void write(int arg0) {
+- if (pos>=size) {
+- expandSize();
+- }
+- buf[pos++]=(byte)arg0;
++ buf[pos++] = (byte)arg0;
++ }
++
++ public byte[] toByteArray() {
++ byte result[] = new byte[pos];
++ System.arraycopy(buf, 0, result, 0, pos);
++ return result;
++ }
++
++ public void reset() {
++ pos = 0;
++ }
++
++ private void expandSize(int newPos) {
++ int newSize = size;
++ while (newPos > newSize) {
++ newSize = newSize<<2;
+ }
+- /** @inheritDoc */
+- public byte[] toByteArray() {
+- byte result[]=new byte[pos];
+- System.arraycopy(buf,0,result,0,pos);
+- return result;
+- }
+-
+- /** @inheritDoc */
+- public void reset() {
+- pos=0;
+- }
+-
+- /** @inheritDoc */
+- void expandSize() {
+- int newSize=size<<2;
+- byte newBuf[]=new byte[newSize];
+- System.arraycopy(buf,0,newBuf,0,pos);
+- buf=newBuf;
+- size=newSize;
+-
+- }
++ byte newBuf[] = new byte[newSize];
++ System.arraycopy(buf, 0, newBuf, 0, pos);
++ buf = newBuf;
++ size = newSize;
++ }
+ }
+diff -r e5a4a4ec7b21 -r 5e3c766d1809 test/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream/BufferOverflowTest.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream/BufferOverflowTest.java Fri Oct 15 10:55:59 2010 -0400
+@@ -0,0 +1,47 @@
++/*
++ * 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.
++ *
++ * 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 %I% %E%
++ * @bug 6954275
++ * @summary Check that UnsyncByteArrayOutputStream does not
++ * throw ArrayIndexOutOfBoundsException
++ * @compile -XDignore.symbol.file BufferOverflowTest.java
++ * @run main BufferOverflowTest
++ */
++
++import com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStream;
++
++public class BufferOverflowTest {
++
++ public static void main(String[] args) throws Exception {
++ try {
++ UnsyncByteArrayOutputStream out = new UnsyncByteArrayOutputStream();
++ out.write(new byte[(8192) << 2 + 1]);
++ System.out.println("PASSED");
++ } catch (ArrayIndexOutOfBoundsException e) {
++ System.err.println("FAILED, got ArrayIndexOutOfBoundsException");
++ throw new Exception(e);
++ }
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/7146431-java.security_files.patch b/java/openjdk6/files/icedtea/openjdk/7146431-java.security_files.patch
new file mode 100644
index 000000000000..bdcf9789e648
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/7146431-java.security_files.patch
@@ -0,0 +1,82 @@
+# HG changeset patch
+# User mullan
+# Date 1382735486 -3600
+# Fri Oct 25 22:11:26 2013 +0100
+# Node ID 5b485ecccea9064e5036e1bb040fc2af1f773c20
+# Parent 011d86bdcbf8d4fe0016351b775ff1f48f3620a1
+7146431: java.security files out-of-sync
+Reviewed-by: vinnie, xuelei, wetmore
+
+diff -r 011d86bdcbf8 -r 5b485ecccea9 src/share/lib/security/java.security-solaris
+--- jdk/src/share/lib/security/java.security-solaris Mon Jul 15 03:40:16 2013 -0700
++++ jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:11:26 2013 +0100
+@@ -141,6 +141,7 @@
+ com.sun.org.apache.xalan.internal.lib.,\
+ com.sun.org.apache.xalan.internal.res.,\
+ com.sun.org.apache.xalan.internal.templates.,\
++ com.sun.org.apache.xalan.internal.utils.\
+ com.sun.org.apache.xalan.internal.xslt.,\
+ com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
+ com.sun.org.apache.xalan.internal.xsltc.compiler.,\
+diff -r 011d86bdcbf8 -r 5b485ecccea9 src/share/lib/security/java.security-windows
+--- jdk/src/share/lib/security/java.security-windows Mon Jul 15 03:40:16 2013 -0700
++++ jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:11:26 2013 +0100
+@@ -141,6 +141,7 @@
+ com.sun.org.apache.xalan.internal.lib.,\
+ com.sun.org.apache.xalan.internal.res.,\
+ com.sun.org.apache.xalan.internal.templates.,\
++ com.sun.org.apache.xalan.internal.utils.\
+ com.sun.org.apache.xalan.internal.xslt.,\
+ com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
+ com.sun.org.apache.xalan.internal.xsltc.compiler.,\
+diff -r 011d86bdcbf8 -r 5b485ecccea9 test/java/lang/SecurityManager/CheckPackageAccess.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:11:26 2013 +0100
+@@ -0,0 +1,47 @@
++/*
++ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++/*
++ * @test
++ * @bug 7146431
++ * @summary Test that internal JAXP packages cannot be accessed
++ */
++
++public class CheckPackageAccess {
++
++ public static void main(String[] args) throws Exception {
++
++ String[] pkgs = new String[] {
++ "com.sun.org.apache.xerces.internal.utils.",
++ "com.sun.org.apache.xalan.internal.utils." };
++ SecurityManager sm = new SecurityManager();
++ System.setSecurityManager(sm);
++ for (String pkg : pkgs) {
++ System.out.println("Checking package access for " + pkg);
++ try {
++ sm.checkPackageAccess(pkg);
++ throw new Exception("Expected SecurityException not thrown");
++ } catch (SecurityException se) { }
++ }
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/7196533-timezone_bottleneck.patch b/java/openjdk6/files/icedtea/openjdk/7196533-timezone_bottleneck.patch
new file mode 100644
index 000000000000..c8b894073a74
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/7196533-timezone_bottleneck.patch
@@ -0,0 +1,75 @@
+# HG changeset patch
+# User coffeys
+# Date 1381845864 -3600
+# Tue Oct 15 15:04:24 2013 +0100
+# Node ID 5d81a5f8a3791316367990b35b1ad5faef42d773
+# Parent 77af6e10b333347cd882027ab1bb9a3366278096
+7196533: TimeZone.getDefault() slow due to synchronization bottleneck
+Reviewed-by: okutsu, omajid
+
+diff -r 77af6e10b333 -r 5d81a5f8a379 src/share/classes/java/util/TimeZone.java
+--- jdk/src/share/classes/java/util/TimeZone.java Fri Oct 04 12:22:34 2013 -0400
++++ jdk/src/share/classes/java/util/TimeZone.java Tue Oct 15 15:04:24 2013 +0100
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1996, 2011, 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
+@@ -646,9 +646,15 @@
+ * Returns the default TimeZone in an AppContext if any AppContext
+ * has ever used. null is returned if any AppContext hasn't been
+ * used or if the AppContext doesn't have the default TimeZone.
++ *
++ * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
++ * been loaded. If so, it implies that AWTSecurityManager is not our
++ * SecurityManager and we can use a local static variable.
++ * This works around a build time issue.
+ */
+- private synchronized static TimeZone getDefaultInAppContext() {
+- javaAWTAccess = SharedSecrets.getJavaAWTAccess();
++ private static TimeZone getDefaultInAppContext() {
++ // JavaAWTAccess provides access implementation-private methods without using reflection.
++ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+ if (javaAWTAccess == null) {
+ return mainAppContextDefault;
+ } else {
+@@ -670,9 +676,15 @@
+ * tz. null is handled special: do nothing if any AppContext
+ * hasn't been used, remove the default TimeZone in the
+ * AppContext otherwise.
++ *
++ * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
++ * been loaded. If so, it implies that AWTSecurityManager is not our
++ * SecurityManager and we can use a local static variable.
++ * This works around a build time issue.
+ */
+- private synchronized static void setDefaultInAppContext(TimeZone tz) {
+- javaAWTAccess = SharedSecrets.getJavaAWTAccess();
++ private static void setDefaultInAppContext(TimeZone tz) {
++ // JavaAWTAccess provides access implementation-private methods without using reflection.
++ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+ if (javaAWTAccess == null) {
+ mainAppContextDefault = tz;
+ } else {
+@@ -736,18 +748,8 @@
+ static final String GMT_ID = "GMT";
+ private static final int GMT_ID_LENGTH = 3;
+
+- /*
+- * Provides access implementation-private methods without using reflection
+- *
+- * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
+- * been loaded. If so, it implies that AWTSecurityManager is not our
+- * SecurityManager and we can use a local static variable.
+- * This works around a build time issue.
+- */
+- private static JavaAWTAccess javaAWTAccess;
+-
+ // a static TimeZone we can reference if no AppContext is in place
+- private static TimeZone mainAppContextDefault;
++ private static volatile TimeZone mainAppContextDefault;
+
+
+ /**
diff --git a/java/openjdk6/files/icedtea/openjdk/8000450-restrict_access.patch b/java/openjdk6/files/icedtea/openjdk/8000450-restrict_access.patch
new file mode 100644
index 000000000000..41073719f276
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8000450-restrict_access.patch
@@ -0,0 +1,108 @@
+# HG changeset patch
+# User coffeys
+# Date 1382735937 -3600
+# Fri Oct 25 22:18:57 2013 +0100
+# Node ID f7a7c7d70e4968eb99e42f812c59900f545d7fa7
+# Parent 695dd7ceb9e34fd4058374de63964c205f061002
+8000450: Restrict access to com/sun/corba/se/impl package
+Reviewed-by: alanb, chegar, lancea
+
+diff -r 695dd7ceb9e3 -r f7a7c7d70e49 src/share/lib/security/java.security
+--- jdk/src/share/lib/security/java.security Fri Oct 25 22:17:00 2013 +0100
++++ jdk/src/share/lib/security/java.security Fri Oct 25 22:18:57 2013 +0100
+@@ -128,6 +128,7 @@
+ # corresponding RuntimePermission ("accessClassInPackage."+package) has
+ # been granted.
+ package.access=sun.,\
++ com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+@@ -164,6 +165,7 @@
+ # checkPackageDefinition.
+ #
+ package.definition=sun.,\
++ com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+diff -r 695dd7ceb9e3 -r f7a7c7d70e49 src/share/lib/security/java.security-solaris
+--- jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:17:00 2013 +0100
++++ jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:18:57 2013 +0100
+@@ -129,6 +129,7 @@
+ # corresponding RuntimePermission ("accessClassInPackage."+package) has
+ # been granted.
+ package.access=sun.,\
++ com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+@@ -166,6 +167,7 @@
+ # checkPackageDefinition.
+ #
+ package.definition=sun.,\
++ com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+diff -r 695dd7ceb9e3 -r f7a7c7d70e49 src/share/lib/security/java.security-windows
+--- jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:17:00 2013 +0100
++++ jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:18:57 2013 +0100
+@@ -129,6 +129,7 @@
+ # corresponding RuntimePermission ("accessClassInPackage."+package) has
+ # been granted.
+ package.access=sun.,\
++ com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+@@ -167,6 +168,7 @@
+ # checkPackageDefinition.
+ #
+ package.definition=sun.,\
++ com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+diff -r 695dd7ceb9e3 -r f7a7c7d70e49 test/java/lang/SecurityManager/CheckPackageAccess.java
+--- jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:17:00 2013 +0100
++++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:18:57 2013 +0100
+@@ -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
+@@ -23,8 +23,8 @@
+
+ /*
+ * @test
+- * @bug 7146431
+- * @summary Test that internal JAXP packages cannot be accessed
++ * @bug 7146431 8000450
++ * @summary Test that internal packages cannot be accessed
+ */
+
+ public class CheckPackageAccess {
+@@ -32,6 +32,7 @@
+ public static void main(String[] args) throws Exception {
+
+ String[] pkgs = new String[] {
++ "com.sun.corba.se.impl.",
+ "com.sun.org.apache.xerces.internal.utils.",
+ "com.sun.org.apache.xalan.internal.utils." };
+ SecurityManager sm = new SecurityManager();
+@@ -40,7 +41,11 @@
+ System.out.println("Checking package access for " + pkg);
+ try {
+ sm.checkPackageAccess(pkg);
+- throw new Exception("Expected SecurityException not thrown");
++ throw new Exception("Expected PackageAccess SecurityException not thrown");
++ } catch (SecurityException se) { }
++ try {
++ sm.checkPackageDefinition(pkg);
++ throw new Exception("Expected PackageDefinition SecurityException not thrown");
+ } catch (SecurityException se) { }
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8002070-remove_logger_stack_search.patch b/java/openjdk6/files/icedtea/openjdk/8002070-remove_logger_stack_search.patch
new file mode 100644
index 000000000000..889b00a1da59
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8002070-remove_logger_stack_search.patch
@@ -0,0 +1,658 @@
+# HG changeset patch
+# User jgish
+# Date 1381898393 -3600
+# Wed Oct 16 05:39:53 2013 +0100
+# Node ID e56220b54fe2d0f09ee151b28d6e8495cea2136f
+# Parent 1ed7c9cea8c508e60d6df30c046ab48b1f1d3ab9
+8002070: Remove the stack search for a resource bundle for Logger to use
+Summary: The fragile, vulnerable, stack crawling has been eliminated from findResourceBundle(String)
+Reviewed-by: mchung
+
+diff -r 1ed7c9cea8c5 -r e56220b54fe2 src/share/classes/java/util/logging/Logger.java
+--- jdk/src/share/classes/java/util/logging/Logger.java Wed Oct 16 05:10:54 2013 +0100
++++ jdk/src/share/classes/java/util/logging/Logger.java Wed Oct 16 05:39:53 2013 +0100
+@@ -26,9 +26,17 @@
+
+ package java.util.logging;
+
+-import java.util.*;
+-import java.security.*;
+ import java.lang.ref.WeakReference;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
++import java.util.ArrayList;
++import java.util.Iterator;
++import java.util.Locale;
++import java.util.MissingResourceException;
++import java.util.ResourceBundle;
++import java.util.concurrent.CopyOnWriteArrayList;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+
+ /**
+ * A Logger object is used to log messages for a specific
+@@ -97,14 +105,8 @@
+ * <p>
+ * When mapping ResourceBundle names to ResourceBundles, the Logger
+ * will first try to use the Thread's ContextClassLoader. If that
+- * is null it will try the SystemClassLoader instead. As a temporary
+- * transition feature in the initial implementation, if the Logger is
+- * unable to locate a ResourceBundle from the ContextClassLoader or
+- * SystemClassLoader the Logger will also search up the class stack
+- * and use successive calling ClassLoaders to try to locate a ResourceBundle.
+- * (This call stack search is to allow containers to transition to
+- * using ContextClassLoaders and is likely to be removed in future
+- * versions.)
++ * is null it will try the
++ * {@linkplain java.lang.ClassLoader#getSystemClassLoader() system ClassLoader} instead.
+ * <p>
+ * Formatting (including localization) is the responsibility of
+ * the output Handler, which will typically call a Formatter.
+@@ -1297,12 +1299,6 @@
+ return useParentHandlers;
+ }
+
+- // Private utility method to map a resource bundle name to an
+- // actual resource bundle, using a simple one-entry cache.
+- // Returns null for a null name.
+- // May also return null if we can't find the resource bundle and
+- // there is no suitable previous cached value.
+-
+ static final String SYSTEM_LOGGER_RB_NAME = "sun.util.logging.resources.logging";
+
+ private static ResourceBundle findSystemResourceBundle(final Locale locale) {
+@@ -1320,6 +1316,16 @@
+ });
+ }
+
++ /**
++ * Private utility method to map a resource bundle name to an
++ * actual resource bundle, using a simple one-entry cache.
++ * Returns null for a null name.
++ * May also return null if we can't find the resource bundle and
++ * there is no suitable previous cached value.
++ *
++ * @param name the ResourceBundle to locate
++ * @return ResourceBundle specified by name or null if not found
++ */
+ private synchronized ResourceBundle findResourceBundle(String name) {
+ // Return a null bundle for a null name.
+ if (name == null) {
+@@ -1329,8 +1335,8 @@
+ Locale currentLocale = Locale.getDefault();
+
+ // Normally we should hit on our simple one entry cache.
+- if (catalog != null && currentLocale == catalogLocale
+- && name == catalogName) {
++ if (catalog != null && currentLocale.equals(catalogLocale)
++ && name.equals(catalogName)) {
+ return catalog;
+ }
+
+@@ -1341,8 +1347,8 @@
+ return catalog;
+ }
+
+- // Use the thread's context ClassLoader. If there isn't one,
+- // use the SystemClassloader.
++ // Use the thread's context ClassLoader. If there isn't one, use the
++ // {@linkplain java.lang.ClassLoader#getSystemClassLoader() system ClassLoader}.
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null) {
+ cl = ClassLoader.getSystemClassLoader();
+@@ -1353,45 +1359,8 @@
+ catalogLocale = currentLocale;
+ return catalog;
+ } catch (MissingResourceException ex) {
+- // Woops. We can't find the ResourceBundle in the default
+- // ClassLoader. Drop through.
++ return null;
+ }
+-
+-
+- // Fall back to searching up the call stack and trying each
+- // calling ClassLoader.
+- for (int ix = 0; ; ix++) {
+- Class clz = sun.reflect.Reflection.getCallerClass(ix);
+- if (clz == null) {
+- break;
+- }
+- ClassLoader cl2 = clz.getClassLoader();
+- if (cl2 == null) {
+- cl2 = ClassLoader.getSystemClassLoader();
+- }
+- if (cl == cl2) {
+- // We've already checked this classloader.
+- continue;
+- }
+- cl = cl2;
+- try {
+- catalog = ResourceBundle.getBundle(name, currentLocale, cl);
+- catalogName = name;
+- catalogLocale = currentLocale;
+- return catalog;
+- } catch (MissingResourceException ex) {
+- // Ok, this one didn't work either.
+- // Drop through, and try the next one.
+- }
+- }
+-
+- if (name.equals(catalogName)) {
+- // Return the previous cached value for that name.
+- // This may be null.
+- return catalog;
+- }
+- // Sorry, we're out of luck.
+- return null;
+ }
+
+ // Private utility method to initialize our one entry
+@@ -1403,8 +1372,7 @@
+ if (name == null) {
+ return;
+ }
+- ResourceBundle rb = findResourceBundle(name);
+- if (rb == null) {
++ if (findResourceBundle(name) == null) {
+ // We've failed to find an expected ResourceBundle.
+ throw new MissingResourceException("Can't find " + name + " bundle", name, "");
+ }
+diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/ClassPathTestBundle_en.properties
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/ClassPathTestBundle_en.properties Wed Oct 16 05:39:53 2013 +0100
+@@ -0,0 +1,25 @@
++#
++# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++#
++# This code is free software; you can redistribute it and/or modify it
++# under the terms of the GNU General Public License version 2 only, as
++# published by the Free Software Foundation.
++#
++# This code is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++# version 2 for more details (a copy is included in the LICENSE file that
++# accompanied this code).
++#
++# You should have received a copy of the GNU General Public License version
++# 2 along with this work; if not, write to the Free Software Foundation,
++# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++#
++# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++# or visit www.oracle.com if you need additional information or have any
++# questions.
++#
++sample1=translation #2 for sample1
++sample2=translation #2 for sample2
++supports-test=ResourceBundleSearchTest
+diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Wed Oct 16 05:39:53 2013 +0100
+@@ -0,0 +1,89 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++import java.lang.reflect.InvocationTargetException;
++import java.lang.reflect.Method;
++import java.net.URL;
++import java.net.URLClassLoader;
++
++/**
++ * This class is used to ensure that a resource bundle loadable by a classloader
++ * is on the caller's stack, but not on the classpath or TCCL to ensure that
++ * Logger.getLogger() can't load the bundle via a stack search
++ *
++ * @author Jim Gish
++ */
++public class IndirectlyLoadABundle {
++
++ private final static String rbName = "StackSearchableResource";
++
++ public boolean loadAndTest() throws Throwable {
++ // Find out where we are running from so we can setup the URLClassLoader URLs
++ // test.src and test.classes will be set if running in jtreg, but probably
++ // not otherwise
++ String testDir = System.getProperty("test.src", System.getProperty("user.dir"));
++ String testClassesDir = System.getProperty("test.classes",
++ System.getProperty("user.dir"));
++ String sep = System.getProperty("file.separator");
++ URL[] urls = new URL[2];
++
++ // Allow for both jtreg and standalone cases here
++ urls[0] = new URL("file://" + testDir + sep + "resources" + sep);
++ urls[1] = new URL("file://" + testClassesDir + sep );
++ System.out.println("INFO: urls[0] = " + urls[0]);
++ System.out.println("INFO: urls[1] = " + urls[1]);
++
++ // Make sure we can find it via the URLClassLoader
++ URLClassLoader yetAnotherResourceCL = new URLClassLoader(urls, null);
++ if (!testForValidResourceSetup(yetAnotherResourceCL)) {
++ throw new Exception("Couldn't directly load bundle " + rbName
++ + " as expected. Test config problem");
++ }
++ // But it shouldn't be available via the system classloader
++ ClassLoader myCL = this.getClass().getClassLoader();
++ if (testForValidResourceSetup(myCL)) {
++ throw new Exception("Was able to directly load bundle " + rbName
++ + " from " + myCL + " but shouldn't have been"
++ + " able to. Test config problem");
++ }
++
++ Class<?> loadItUpClazz = Class.forName("LoadItUp", true, yetAnotherResourceCL);
++ ClassLoader actual = loadItUpClazz.getClassLoader();
++ if (actual != yetAnotherResourceCL) {
++ throw new Exception("LoadItUp was loaded by an unexpected CL: " + actual);
++ }
++ Object loadItUp = loadItUpClazz.newInstance();
++ Method testMethod = loadItUpClazz.getMethod("test", String.class);
++ try {
++ return (Boolean) testMethod.invoke(loadItUp, rbName);
++ } catch (InvocationTargetException ex) {
++ throw ex.getTargetException();
++ }
++ }
++
++ private boolean testForValidResourceSetup(ClassLoader cl) {
++ // First make sure the test environment is setup properly and the bundle actually
++ // exists
++ return ResourceBundleSearchTest.isOnClassPath(rbName, cl);
++ }
++}
+diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/LoadItUp.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/LoadItUp.java Wed Oct 16 05:39:53 2013 +0100
+@@ -0,0 +1,62 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++import java.util.MissingResourceException;
++import java.util.logging.Logger;
++
++/*
++ * This class is loaded onto the call stack when the test method is called
++ * and then its classloader can be used to find a property bundle in the same
++ * directory as the class. However, Logger is not allowed
++ * to find the bundle by looking up the stack for this classloader.
++ * We verify that this cannot happen.
++ *
++ * @author Jim Gish
++ */
++public class LoadItUp {
++
++ private final static boolean DEBUG = false;
++
++ public Boolean test(String rbName) throws Exception {
++ // we should not be able to find the resource in this directory via
++ // getLogger calls. The only way that would be possible given this setup
++ // is that if Logger.getLogger searched up the call stack
++ return lookupBundle(rbName);
++ }
++
++ private boolean lookupBundle(String rbName) {
++ // See if Logger.getLogger can find the resource in this directory
++ try {
++ Logger aLogger = Logger.getLogger("NestedLogger", rbName);
++ } catch (MissingResourceException re) {
++ if (DEBUG) {
++ System.out.println(
++ "As expected, LoadItUp.lookupBundle() did not find the bundle "
++ + rbName);
++ }
++ return false;
++ }
++ System.out.println("FAILED: LoadItUp.lookupBundle() found the bundle "
++ + rbName + " using a stack search.");
++ return true;
++ }
++}
+diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Wed Oct 16 05:39:53 2013 +0100
+@@ -0,0 +1,249 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++/*
++ * @test
++ * @bug 8010127
++ * @summary Remove the stack search for a resource bundle Logger to use
++ * @author Jim Gish
++ * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp
++ * @run main ResourceBundleSearchTest
++ */
++import java.net.URL;
++import java.net.URLClassLoader;
++import java.util.ArrayList;
++import java.util.List;
++import java.util.Locale;
++import java.util.MissingResourceException;
++import java.util.ResourceBundle;
++import java.util.logging.Logger;
++
++public class ResourceBundleSearchTest {
++
++ private final static boolean DEBUG = false;
++ private final static String LOGGER_PREFIX = "myLogger.";
++ private static int loggerNum = 0;
++ private final static String PROP_RB_NAME = "ClassPathTestBundle";
++ private final static String TCCL_TEST_BUNDLE = "ContextClassLoaderTestBundle";
++
++ private static int numPass = 0;
++ private static int numFail = 0;
++ private static List<String> msgs = new ArrayList<String>();
++
++ public static void main(String[] args) throws Throwable {
++ ResourceBundleSearchTest test = new ResourceBundleSearchTest();
++ test.runTests();
++ }
++
++ private void runTests() throws Throwable {
++ // ensure we are using en as the default Locale so we can find the resource
++ Locale.setDefault(Locale.ENGLISH);
++
++ String testClasses = System.getProperty("test.classes");
++ System.out.println( "test.classes = " + testClasses );
++
++ ClassLoader myClassLoader = ClassLoader.getSystemClassLoader();
++
++ // Find out where we are running from so we can setup the URLClassLoader URL
++ String userDir = System.getProperty("user.dir");
++ String testDir = System.getProperty("test.src", userDir);
++ String sep = System.getProperty("file.separator");
++
++ URL[] urls = new URL[1];
++ urls[0] = new URL("file://" + testDir + sep + "resources" + sep);
++ URLClassLoader rbClassLoader = new URLClassLoader(urls);
++
++ // Test 1 - can we find a Logger bundle from doing a stack search?
++ // We shouldn't be able to
++ assertFalse(testGetBundleFromStackSearch(), "testGetBundleFromStackSearch");
++
++ // Test 2 - can we find a Logger bundle off of the Thread context class
++ // loader? We should be able to.
++ assertTrue(
++ testGetBundleFromTCCL(TCCL_TEST_BUNDLE, rbClassLoader),
++ "testGetBundleFromTCCL");
++
++ // Test 3 - Can we find a Logger bundle from the classpath? We should be
++ // able to, but ....
++ // We check to see if the bundle is on the classpath or not so that this
++ // will work standalone. In the case of jtreg/samevm,
++ // the resource bundles are not on the classpath. Running standalone
++ // (or othervm), they are
++ if (isOnClassPath(PROP_RB_NAME, myClassLoader)) {
++ debug("We should be able to see " + PROP_RB_NAME + " on the classpath");
++ assertTrue(testGetBundleFromSystemClassLoader(PROP_RB_NAME),
++ "testGetBundleFromSystemClassLoader");
++ } else {
++ debug("We should not be able to see " + PROP_RB_NAME + " on the classpath");
++ assertFalse(testGetBundleFromSystemClassLoader(PROP_RB_NAME),
++ "testGetBundleFromSystemClassLoader");
++ }
++
++ report();
++ }
++
++ private void report() throws Exception {
++ System.out.println("Num passed = " + numPass + " Num failed = " + numFail);
++ if (numFail > 0) {
++ // We only care about the messages if they were errors
++ for (String msg : msgs) {
++ System.out.println(msg);
++ }
++ throw new Exception(numFail + " out of " + (numPass + numFail)
++ + " tests failed.");
++ }
++ }
++
++ public void assertTrue(boolean testResult, String testName) {
++ if (testResult) {
++ numPass++;
++ } else {
++ numFail++;
++ System.out.println("FAILED: " + testName
++ + " was supposed to return true but did NOT!");
++ }
++ }
++
++ public void assertFalse(boolean testResult, String testName) {
++ if (!testResult) {
++ numPass++;
++ } else {
++ numFail++;
++ System.out.println("FAILED: " + testName
++ + " was supposed to return false but did NOT!");
++ }
++ }
++
++ public boolean testGetBundleFromStackSearch() throws Throwable {
++ // This should fail. This was the old functionality to search up the
++ // caller's call stack
++ IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle();
++ return indirectLoader.loadAndTest();
++ }
++
++ public boolean testGetBundleFromTCCL(String bundleName,
++ ClassLoader setOnTCCL) throws InterruptedException {
++ // This should succeed. We should be able to get the bundle from the
++ // thread context class loader
++ debug("Looking for " + bundleName + " using TCCL");
++ LoggingThread lr = new LoggingThread(bundleName, setOnTCCL);
++ lr.start();
++ synchronized (lr) {
++ try {
++ lr.wait();
++ } catch (InterruptedException ex) {
++ throw ex;
++ }
++ }
++ msgs.add(lr.msg);
++ return lr.foundBundle;
++ }
++
++ /*
++ * @param String bundleClass
++ * @param ClassLoader to use for search
++ * @return true iff bundleClass is on system classpath
++ */
++ public static boolean isOnClassPath(String baseName, ClassLoader cl) {
++ ResourceBundle rb = null;
++ try {
++ rb = ResourceBundle.getBundle(baseName, Locale.getDefault(), cl);
++ System.out.println("INFO: Found bundle " + baseName + " on " + cl);
++ } catch (MissingResourceException e) {
++ System.out.println("INFO: Could not find bundle " + baseName + " on " + cl);
++ return false;
++ }
++ return (rb != null);
++ }
++
++ private static String newLoggerName() {
++ // we need a new logger name every time we attempt to find a bundle via
++ // the Logger.getLogger call, so we'll simply tack on an integer which
++ // we increment each time this is called
++ loggerNum++;
++ return LOGGER_PREFIX + loggerNum;
++ }
++
++ public boolean testGetBundleFromSystemClassLoader(String bundleName) {
++ // this should succeed if the bundle is on the system classpath.
++ try {
++ Logger aLogger = Logger.getLogger(ResourceBundleSearchTest.newLoggerName(),
++ bundleName);
++ } catch (MissingResourceException re) {
++ msgs.add("INFO: testGetBundleFromSystemClassLoader() did not find bundle "
++ + bundleName);
++ return false;
++ }
++ msgs.add("INFO: testGetBundleFromSystemClassLoader() found the bundle "
++ + bundleName);
++ return true;
++ }
++
++ public static class LoggingThread extends Thread {
++
++ boolean foundBundle = false;
++ String msg = null;
++ ClassLoader clToSetOnTCCL = null;
++ String bundleName = null;
++
++ public LoggingThread(String bundleName) {
++ this.bundleName = bundleName;
++ }
++
++ public LoggingThread(String bundleName, ClassLoader setOnTCCL) {
++ this.clToSetOnTCCL = setOnTCCL;
++ this.bundleName = bundleName;
++ }
++
++ public void run() {
++ boolean setTCCL = false;
++ try {
++ if (clToSetOnTCCL != null) {
++ Thread.currentThread().setContextClassLoader(clToSetOnTCCL);
++ setTCCL = true;
++ }
++ // this should succeed if the bundle is on the system classpath.
++ try {
++ Logger aLogger = Logger.getLogger(ResourceBundleSearchTest.newLoggerName(),
++ bundleName);
++ msg = "INFO: LoggingRunnable() found the bundle " + bundleName
++ + (setTCCL ? " with " : " without ") + "setting the TCCL";
++ foundBundle = true;
++ } catch (MissingResourceException re) {
++ msg = "INFO: LoggingRunnable() did not find the bundle " + bundleName
++ + (setTCCL ? " with " : " without ") + "setting the TCCL";
++ foundBundle = false;
++ }
++ } catch (Throwable e) {
++ e.printStackTrace();
++ System.exit(1);
++ }
++ }
++ }
++
++ private void debug(String msg) {
++ if (DEBUG) {
++ System.out.println(msg);
++ }
++ }
++}
+diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/resources/ContextClassLoaderTestBundle_en.properties
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/resources/ContextClassLoaderTestBundle_en.properties Wed Oct 16 05:39:53 2013 +0100
+@@ -0,0 +1,25 @@
++#
++# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++#
++# This code is free software; you can redistribute it and/or modify it
++# under the terms of the GNU General Public License version 2 only, as
++# published by the Free Software Foundation.
++#
++# This code is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++# version 2 for more details (a copy is included in the LICENSE file that
++# accompanied this code).
++#
++# You should have received a copy of the GNU General Public License version
++# 2 along with this work; if not, write to the Free Software Foundation,
++# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++#
++# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++# or visit www.oracle.com if you need additional information or have any
++# questions.
++#
++sample1=translation #3 for sample1
++sample2=translation #3 for sample2
++supports-test=ResourceBundleSearchTest
+diff -r 1ed7c9cea8c5 -r e56220b54fe2 test/java/util/logging/bundlesearch/resources/StackSearchableResource_en.properties
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/resources/StackSearchableResource_en.properties Wed Oct 16 05:39:53 2013 +0100
+@@ -0,0 +1,25 @@
++#
++# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++#
++# This code is free software; you can redistribute it and/or modify it
++# under the terms of the GNU General Public License version 2 only, as
++# published by the Free Software Foundation.
++#
++# This code is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++# version 2 for more details (a copy is included in the LICENSE file that
++# accompanied this code).
++#
++# You should have received a copy of the GNU General Public License version
++# 2 along with this work; if not, write to the Free Software Foundation,
++# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++#
++# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++# or visit www.oracle.com if you need additional information or have any
++# questions.
++#
++sample1=translation #4 for sample1
++sample2=translation #4 for sample2
++supports-test=ResourceBundleSearchTest
diff --git a/java/openjdk6/files/icedtea/openjdk/8003992-embedded_nulls.patch b/java/openjdk6/files/icedtea/openjdk/8003992-embedded_nulls.patch
new file mode 100644
index 000000000000..88c94927c7dd
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8003992-embedded_nulls.patch
@@ -0,0 +1,1026 @@
+# HG changeset patch
+# User dxu
+# Date 1383015918 0
+# Tue Oct 29 03:05:18 2013 +0000
+# Node ID 8ad2eb12bf42f2564fdf80a7236e4046046a4f4e
+# Parent 44a49c18eba21f97222a2cde09f6536a7f365363
+8003992: File and other classes in java.io do not handle embedded nulls properly
+Summary: Have every file operation done with File, FileInputStream, FileOutputStream, or RandomAccessFile that involves a file path containing NUL fail. Also reviewed by fweimer@redhat.com
+Reviewed-by: alanb, sherman, ahgross, mduigou, dholmes, aph, plevart, martin
+
+diff -r 44a49c18eba2 -r 8ad2eb12bf42 src/share/classes/java/io/File.java
+--- jdk/src/share/classes/java/io/File.java Fri Sep 06 09:38:10 2013 -0700
++++ jdk/src/share/classes/java/io/File.java Tue Oct 29 03:05:18 2013 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+@@ -153,6 +153,32 @@
+ private String path;
+
+ /**
++ * Enum type that indicates the status of a file path.
++ */
++ private static enum PathStatus { INVALID, CHECKED };
++
++ /**
++ * The flag indicating whether the file path is invalid.
++ */
++ private transient PathStatus status = null;
++
++ /**
++ * Check if the file has an invalid path. Currently, the inspection of
++ * a file path is very limited, and it only covers Nul character check.
++ * Returning true means the path is definitely invalid/garbage. But
++ * returning false does not guarantee that the path is valid.
++ *
++ * @return true if the file path is invalid.
++ */
++ final boolean isInvalid() {
++ if (status == null) {
++ status = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED
++ : PathStatus.INVALID;
++ }
++ return status == PathStatus.INVALID;
++ }
++
++ /**
+ * The length of this abstract pathname's prefix, or zero if it has no
+ * prefix.
+ */
+@@ -573,6 +599,9 @@
+ * @since JDK1.1
+ */
+ public String getCanonicalPath() throws IOException {
++ if (isInvalid()) {
++ throw new IOException("Invalid file path");
++ }
+ return fs.canonicalize(fs.resolve(this));
+ }
+
+@@ -637,6 +666,9 @@
+ */
+ @Deprecated
+ public URL toURL() throws MalformedURLException {
++ if (isInvalid()) {
++ throw new MalformedURLException("Invalid file path");
++ }
+ return new URL("file", "", slashify(getAbsolutePath(), isDirectory()));
+ }
+
+@@ -705,6 +737,9 @@
+ if (security != null) {
+ security.checkRead(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.checkAccess(this, FileSystem.ACCESS_READ);
+ }
+
+@@ -727,6 +762,9 @@
+ if (security != null) {
+ security.checkWrite(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.checkAccess(this, FileSystem.ACCESS_WRITE);
+ }
+
+@@ -747,6 +785,9 @@
+ if (security != null) {
+ security.checkRead(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return ((fs.getBooleanAttributes(this) & FileSystem.BA_EXISTS) != 0);
+ }
+
+@@ -768,6 +809,9 @@
+ if (security != null) {
+ security.checkRead(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return ((fs.getBooleanAttributes(this) & FileSystem.BA_DIRECTORY)
+ != 0);
+ }
+@@ -792,6 +836,9 @@
+ if (security != null) {
+ security.checkRead(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return ((fs.getBooleanAttributes(this) & FileSystem.BA_REGULAR) != 0);
+ }
+
+@@ -818,6 +865,9 @@
+ if (security != null) {
+ security.checkRead(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return ((fs.getBooleanAttributes(this) & FileSystem.BA_HIDDEN) != 0);
+ }
+
+@@ -840,6 +890,9 @@
+ if (security != null) {
+ security.checkRead(path);
+ }
++ if (isInvalid()) {
++ return 0L;
++ }
+ return fs.getLastModifiedTime(this);
+ }
+
+@@ -862,6 +915,9 @@
+ if (security != null) {
+ security.checkRead(path);
+ }
++ if (isInvalid()) {
++ return 0L;
++ }
+ return fs.getLength(this);
+ }
+
+@@ -897,6 +953,9 @@
+ public boolean createNewFile() throws IOException {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) security.checkWrite(path);
++ if (isInvalid()) {
++ throw new IOException("Invalid file path");
++ }
+ return fs.createFileExclusively(path, false);
+ }
+
+@@ -918,6 +977,9 @@
+ if (security != null) {
+ security.checkDelete(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.delete(this);
+ }
+
+@@ -953,6 +1015,9 @@
+ if (security != null) {
+ security.checkDelete(path);
+ }
++ if (isInvalid()) {
++ return;
++ }
+ DeleteOnExitHook.add(path);
+ }
+
+@@ -987,6 +1052,9 @@
+ if (security != null) {
+ security.checkRead(path);
+ }
++ if (isInvalid()) {
++ return null;
++ }
+ return fs.list(this);
+ }
+
+@@ -1168,6 +1236,9 @@
+ if (security != null) {
+ security.checkWrite(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.createDirectory(this);
+ }
+
+@@ -1239,6 +1310,12 @@
+ security.checkWrite(path);
+ security.checkWrite(dest.path);
+ }
++ if (dest == null) {
++ throw new NullPointerException();
++ }
++ if (this.isInvalid() || dest.isInvalid()) {
++ return false;
++ }
+ return fs.rename(this, dest);
+ }
+
+@@ -1274,6 +1351,9 @@
+ if (security != null) {
+ security.checkWrite(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.setLastModifiedTime(this, time);
+ }
+
+@@ -1299,6 +1379,9 @@
+ if (security != null) {
+ security.checkWrite(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.setReadOnly(this);
+ }
+
+@@ -1333,6 +1416,9 @@
+ if (security != null) {
+ security.checkWrite(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.setPermission(this, FileSystem.ACCESS_WRITE, writable, ownerOnly);
+ }
+
+@@ -1399,6 +1485,9 @@
+ if (security != null) {
+ security.checkWrite(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.setPermission(this, FileSystem.ACCESS_READ, readable, ownerOnly);
+ }
+
+@@ -1468,6 +1557,9 @@
+ if (security != null) {
+ security.checkWrite(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.setPermission(this, FileSystem.ACCESS_EXECUTE, executable, ownerOnly);
+ }
+
+@@ -1522,6 +1614,9 @@
+ if (security != null) {
+ security.checkExec(path);
+ }
++ if (isInvalid()) {
++ return false;
++ }
+ return fs.checkAccess(this, FileSystem.ACCESS_EXECUTE);
+ }
+
+@@ -1597,6 +1692,9 @@
+ sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
+ sm.checkRead(path);
+ }
++ if (isInvalid()) {
++ return 0L;
++ }
+ return fs.getSpace(this, FileSystem.SPACE_TOTAL);
+ }
+
+@@ -1613,7 +1711,7 @@
+ * makes no guarantee that write operations to this file system
+ * will succeed.
+ *
+- * @return The number of unallocated bytes on the partition <tt>0L</tt>
++ * @return The number of unallocated bytes on the partition or <tt>0L</tt>
+ * if the abstract pathname does not name a partition. This
+ * value will be less than or equal to the total file system size
+ * returned by {@link #getTotalSpace}.
+@@ -1632,6 +1730,9 @@
+ sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
+ sm.checkRead(path);
+ }
++ if (isInvalid()) {
++ return 0L;
++ }
+ return fs.getSpace(this, FileSystem.SPACE_FREE);
+ }
+
+@@ -1670,6 +1771,9 @@
+ sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
+ sm.checkRead(path);
+ }
++ if (isInvalid()) {
++ return 0L;
++ }
+ return fs.getSpace(this, FileSystem.SPACE_USABLE);
+ }
+
+@@ -1682,9 +1786,9 @@
+
+ static final String temporaryDirectory = temporaryDirectory();
+ static String temporaryDirectory() {
+- return fs.normalize(
++ return
+ AccessController.doPrivileged(
+- new GetPropertyAction("java.io.tmpdir")));
++ new GetPropertyAction("java.io.tmpdir"));
+ }
+ }
+
+@@ -1735,6 +1839,9 @@
+ File f;
+ do {
+ f = generateFile(prefix, s, directory);
++ if (f.isInvalid()) {
++ throw new IOException("Unable to create temporary file");
++ }
+ } while (!checkAndCreate(f.getPath(), sm, restrictive));
+ return f;
+ }
+diff -r 44a49c18eba2 -r 8ad2eb12bf42 src/share/classes/java/io/FileInputStream.java
+--- jdk/src/share/classes/java/io/FileInputStream.java Fri Sep 06 09:38:10 2013 -0700
++++ jdk/src/share/classes/java/io/FileInputStream.java Tue Oct 29 03:05:18 2013 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1994, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+@@ -132,6 +132,9 @@
+ if (name == null) {
+ throw new NullPointerException();
+ }
++ if (file.isInvalid()) {
++ throw new FileNotFoundException("Invalid file path");
++ }
+ fd = new FileDescriptor();
+ fd.incrementAndGetUseCount();
+ open(name);
+diff -r 44a49c18eba2 -r 8ad2eb12bf42 src/share/classes/java/io/FileOutputStream.java
+--- jdk/src/share/classes/java/io/FileOutputStream.java Fri Sep 06 09:38:10 2013 -0700
++++ jdk/src/share/classes/java/io/FileOutputStream.java Tue Oct 29 03:05:18 2013 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1994, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+@@ -200,6 +200,9 @@
+ if (name == null) {
+ throw new NullPointerException();
+ }
++ if (file.isInvalid()) {
++ throw new FileNotFoundException("Invalid file path");
++ }
+ fd = new FileDescriptor();
+ fd.incrementAndGetUseCount();
+ this.append = append;
+diff -r 44a49c18eba2 -r 8ad2eb12bf42 src/share/classes/java/io/RandomAccessFile.java
+--- jdk/src/share/classes/java/io/RandomAccessFile.java Fri Sep 06 09:38:10 2013 -0700
++++ jdk/src/share/classes/java/io/RandomAccessFile.java Tue Oct 29 03:05:18 2013 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1994, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+@@ -228,6 +228,9 @@
+ if (name == null) {
+ throw new NullPointerException();
+ }
++ if (file.isInvalid()) {
++ throw new FileNotFoundException("Invalid file path");
++ }
+ fd = new FileDescriptor();
+ fd.incrementAndGetUseCount();
+ open(name, imode);
+diff -r 44a49c18eba2 -r 8ad2eb12bf42 test/java/io/File/NulFile.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/io/File/NulFile.java Tue Oct 29 03:05:18 2013 +0000
+@@ -0,0 +1,625 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++/* @test
++ * @bug 8003992
++ * @summary Test a file whose path name is embedded with NUL character, and
++ * ensure it is handled correctly.
++ * @author Dan Xu
++ */
++
++import java.io.File;
++import java.io.FileFilter;
++import java.io.FileInputStream;
++import java.io.FileOutputStream;
++import java.io.RandomAccessFile;
++import java.io.FileNotFoundException;
++import java.io.FilenameFilter;
++import java.io.IOException;
++import java.net.MalformedURLException;
++import java.nio.file.InvalidPathException;
++import java.io.ByteArrayInputStream;
++import java.io.ByteArrayOutputStream;
++import java.io.ObjectOutputStream;
++import java.io.ObjectInputStream;
++
++public class NulFile {
++
++ private static final char CHAR_NUL = '\u0000';
++
++ private static final String ExceptionMsg = "Invalid file path";
++
++ public static void main(String[] args) {
++ testFile();
++ testFileInUnix();
++ testFileInWindows();
++ testTempFile();
++ }
++
++ private static void testFile() {
++ test(new File(new StringBuilder().append(CHAR_NUL).toString()));
++ test(new File(
++ new StringBuilder().append("").append(CHAR_NUL).toString()));
++ test(new File(
++ new StringBuilder().append(CHAR_NUL).append("").toString()));
++ }
++
++ private static void testFileInUnix() {
++ String osName = System.getProperty("os.name");
++ if (osName.startsWith("Windows"))
++ return;
++
++ String unixFile = "/";
++ test(unixFile);
++
++ unixFile = "//";
++ test(unixFile);
++
++ unixFile = "data/info";
++ test(unixFile);
++
++ unixFile = "/data/info";
++ test(unixFile);
++
++ unixFile = "//data//info";
++ test(unixFile);
++ }
++
++ private static void testFileInWindows() {
++ String osName = System.getProperty("os.name");
++ if (!osName.startsWith("Windows"))
++ return;
++
++ String windowsFile = "\\";
++ test(windowsFile);
++
++ windowsFile = "\\\\";
++ test(windowsFile);
++
++ windowsFile = "/";
++ test(windowsFile);
++
++ windowsFile = "//";
++ test(windowsFile);
++
++ windowsFile = "/\\";
++ test(windowsFile);
++
++ windowsFile = "\\/";
++ test(windowsFile);
++
++ windowsFile = "data\\info";
++ test(windowsFile);
++
++ windowsFile = "\\data\\info";
++ test(windowsFile);
++
++ windowsFile = "\\\\server\\data\\info";
++ test(windowsFile);
++
++ windowsFile = "z:data\\info";
++ test(windowsFile);
++
++ windowsFile = "z:\\data\\info";
++ test(windowsFile);
++ }
++
++ private static void test(final String name) {
++ int length = name.length();
++
++ for (int i = 0; i <= length; i++) {
++ StringBuilder sbName = new StringBuilder(name);
++ sbName.insert(i, CHAR_NUL);
++ String curName = sbName.toString();
++
++ // test File(String parent, String child)
++ File testFile = new File(curName, "child");
++ test(testFile);
++ testFile = new File("parent", curName);
++ test(testFile);
++
++ // test File(String pathname)
++ testFile = new File(curName);
++ test(testFile);
++
++ // test File(File parent, String child)
++ testFile = new File(new File(curName), "child");
++ test(testFile);
++ testFile = new File(new File("parent"), curName);
++ test(testFile);
++
++ // test FileInputStream
++ testFileInputStream(curName);
++
++ // test FileOutputStream
++ testFileOutputStream(curName);
++
++ // test RandomAccessFile
++ testRandomAccessFile(curName);
++ }
++ }
++
++ private static void testFileInputStream(final String str) {
++ boolean exceptionThrown = false;
++ FileInputStream is = null;
++ try {
++ is = new FileInputStream(str);
++ } catch (FileNotFoundException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("FileInputStream constructor"
++ + " should throw FileNotFoundException");
++ }
++ if (is != null) {
++ throw new RuntimeException("FileInputStream constructor"
++ + " should fail");
++ }
++
++ exceptionThrown = false;
++ is = null;
++ try {
++ is = new FileInputStream(new File(str));
++ } catch (FileNotFoundException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("FileInputStream constructor"
++ + " should throw FileNotFoundException");
++ }
++ if (is != null) {
++ throw new RuntimeException("FileInputStream constructor"
++ + " should fail");
++ }
++ }
++
++ private static void testFileOutputStream(final String str) {
++ boolean exceptionThrown = false;
++ FileOutputStream os = null;
++ try {
++ os = new FileOutputStream(str);
++ } catch (FileNotFoundException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("FileOutputStream constructor"
++ + " should throw FileNotFoundException");
++ }
++ if (os != null) {
++ throw new RuntimeException("FileOutputStream constructor"
++ + " should fail");
++ }
++
++ exceptionThrown = false;
++ os = null;
++ try {
++ os = new FileOutputStream(new File(str));
++ } catch (FileNotFoundException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("FileOutputStream constructor"
++ + " should throw FileNotFoundException");
++ }
++ if (os != null) {
++ throw new RuntimeException("FileOutputStream constructor"
++ + " should fail");
++ }
++ }
++
++ private static void testRandomAccessFile(final String str) {
++ boolean exceptionThrown = false;
++ RandomAccessFile raf = null;
++ String[] modes = {"r", "rw", "rws", "rwd"};
++
++ for (String mode : modes) {
++ try {
++ raf = new RandomAccessFile(str, mode);
++ } catch (FileNotFoundException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("RandomAccessFile constructor"
++ + " should throw FileNotFoundException");
++ }
++ if (raf != null) {
++ throw new RuntimeException("RandomAccessFile constructor"
++ + " should fail");
++ }
++
++ exceptionThrown = false;
++ raf = null;
++ try {
++ raf = new RandomAccessFile(new File(str), mode);
++ } catch (FileNotFoundException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("RandomAccessFile constructor"
++ + " should throw FileNotFoundException");
++ }
++ if (raf != null) {
++ throw new RuntimeException("RandomAccessFile constructor"
++ + " should fail");
++ }
++ }
++ }
++
++ private static void test(File testFile) {
++ test(testFile, false);
++ // test serialization
++ testSerialization(testFile);
++ }
++
++ @SuppressWarnings("deprecation")
++ private static void test(File testFile, boolean derived) {
++ boolean exceptionThrown = false;
++
++ if (testFile == null) {
++ throw new RuntimeException("test file should not be null.");
++ }
++
++ // getPath()
++ if (testFile.getPath().indexOf(CHAR_NUL) < 0) {
++ throw new RuntimeException(
++ "File path should contain Nul character");
++ }
++ // getAbsolutePath()
++ if (testFile.getAbsolutePath().indexOf(CHAR_NUL) < 0) {
++ throw new RuntimeException(
++ "File absolute path should contain Nul character");
++ }
++ // getAbsoluteFile()
++ File derivedAbsFile = testFile.getAbsoluteFile();
++ if (derived) {
++ if (derivedAbsFile.getPath().indexOf(CHAR_NUL) < 0) {
++ throw new RuntimeException(
++ "Derived file path should also contain Nul character");
++ }
++ } else {
++ test(derivedAbsFile, true);
++ }
++ // getCanonicalPath()
++ try {
++ exceptionThrown = false;
++ testFile.getCanonicalPath();
++ } catch (IOException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException(
++ "getCanonicalPath() should throw IOException with"
++ + " message \"" + ExceptionMsg + "\"");
++ }
++ // getCanonicalFile()
++ try {
++ exceptionThrown = false;
++ testFile.getCanonicalFile();
++ } catch (IOException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException(
++ "getCanonicalFile() should throw IOException with"
++ + " message \"" + ExceptionMsg + "\"");
++ }
++ // toURL()
++ try {
++ exceptionThrown = false;
++ testFile.toURL();
++ } catch (MalformedURLException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("toURL() should throw IOException with"
++ + " message \"" + ExceptionMsg + "\"");
++ }
++ // canRead()
++ if (testFile.canRead())
++ throw new RuntimeException("File should not be readable");
++ // canWrite()
++ if (testFile.canWrite())
++ throw new RuntimeException("File should not be writable");
++ // exists()
++ if (testFile.exists())
++ throw new RuntimeException("File should not be existed");
++ // isDirectory()
++ if (testFile.isDirectory())
++ throw new RuntimeException("File should not be a directory");
++ // isFile()
++ if (testFile.isFile())
++ throw new RuntimeException("File should not be a file");
++ // isHidden()
++ if (testFile.isHidden())
++ throw new RuntimeException("File should not be hidden");
++ // lastModified()
++ if (testFile.lastModified() != 0L)
++ throw new RuntimeException("File last modified time should be 0L");
++ // length()
++ if (testFile.length() != 0L)
++ throw new RuntimeException("File length should be 0L");
++ // createNewFile()
++ try {
++ exceptionThrown = false;
++ testFile.createNewFile();
++ } catch (IOException ex) {
++ if (ExceptionMsg.equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException(
++ "createNewFile() should throw IOException with"
++ + " message \"" + ExceptionMsg + "\"");
++ }
++ // delete()
++ if (testFile.delete())
++ throw new RuntimeException("Delete operation should fail");
++ // list()
++ if (testFile.list() != null)
++ throw new RuntimeException("File list() should return null");
++ // list(FilenameFilter)
++ FilenameFilter fnFilter = new FilenameFilter() {
++ @Override
++ public boolean accept(File dir, String name) {
++ return false;
++ }
++ };
++ if (testFile.list(fnFilter) != null) {
++ throw new RuntimeException("File list(FilenameFilter) should"
++ + " return null");
++ }
++ // listFiles()
++ if (testFile.listFiles() != null)
++ throw new RuntimeException("File listFiles() should return null");
++ // listFiles(FilenameFilter)
++ if (testFile.listFiles(fnFilter) != null) {
++ throw new RuntimeException("File listFiles(FilenameFilter)"
++ + " should return null");
++ }
++ // listFiles(FileFilter)
++ FileFilter fFilter = new FileFilter() {
++ @Override
++ public boolean accept(File file) {
++ return false;
++ }
++ };
++ if (testFile.listFiles(fFilter) != null) {
++ throw new RuntimeException("File listFiles(FileFilter)"
++ + " should return null");
++ }
++ // mkdir()
++ if (testFile.mkdir()) {
++ throw new RuntimeException("File should not be able to"
++ + " create directory");
++ }
++ // mkdirs()
++ if (testFile.mkdirs()) {
++ throw new RuntimeException("File should not be able to"
++ + " create directories");
++ }
++ // renameTo(File)
++ if (testFile.renameTo(new File("dest")))
++ throw new RuntimeException("File rename should fail");
++ if (new File("dest").renameTo(testFile))
++ throw new RuntimeException("File rename should fail");
++ try {
++ exceptionThrown = false;
++ testFile.renameTo(null);
++ } catch (NullPointerException ex) {
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("File rename should thrown NPE");
++ }
++ // setLastModified(long)
++ if (testFile.setLastModified(0L)) {
++ throw new RuntimeException("File should fail to set"
++ + " last modified time");
++ }
++ try {
++ exceptionThrown = false;
++ testFile.setLastModified(-1);
++ } catch (IllegalArgumentException ex) {
++ if ("Negative time".equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("File should fail to set"
++ + " last modified time with message \"Negative time\"");
++ }
++ // setReadOnly()
++ if (testFile.setReadOnly())
++ throw new RuntimeException("File should fail to set read-only");
++ // setWritable(boolean writable, boolean ownerOnly)
++ if (testFile.setWritable(true, true))
++ throw new RuntimeException("File should fail to set writable");
++ if (testFile.setWritable(true, false))
++ throw new RuntimeException("File should fail to set writable");
++ if (testFile.setWritable(false, true))
++ throw new RuntimeException("File should fail to set writable");
++ if (testFile.setWritable(false, false))
++ throw new RuntimeException("File should fail to set writable");
++ // setWritable(boolean writable)
++ if (testFile.setWritable(false))
++ throw new RuntimeException("File should fail to set writable");
++ if (testFile.setWritable(true))
++ throw new RuntimeException("File should fail to set writable");
++ // setReadable(boolean readable, boolean ownerOnly)
++ if (testFile.setReadable(true, true))
++ throw new RuntimeException("File should fail to set readable");
++ if (testFile.setReadable(true, false))
++ throw new RuntimeException("File should fail to set readable");
++ if (testFile.setReadable(false, true))
++ throw new RuntimeException("File should fail to set readable");
++ if (testFile.setReadable(false, false))
++ throw new RuntimeException("File should fail to set readable");
++ // setReadable(boolean readable)
++ if (testFile.setReadable(false))
++ throw new RuntimeException("File should fail to set readable");
++ if (testFile.setReadable(true))
++ throw new RuntimeException("File should fail to set readable");
++ // setExecutable(boolean executable, boolean ownerOnly)
++ if (testFile.setExecutable(true, true))
++ throw new RuntimeException("File should fail to set executable");
++ if (testFile.setExecutable(true, false))
++ throw new RuntimeException("File should fail to set executable");
++ if (testFile.setExecutable(false, true))
++ throw new RuntimeException("File should fail to set executable");
++ if (testFile.setExecutable(false, false))
++ throw new RuntimeException("File should fail to set executable");
++ // setExecutable(boolean executable)
++ if (testFile.setExecutable(false))
++ throw new RuntimeException("File should fail to set executable");
++ if (testFile.setExecutable(true))
++ throw new RuntimeException("File should fail to set executable");
++ // canExecute()
++ if (testFile.canExecute())
++ throw new RuntimeException("File should not be executable");
++ // getTotalSpace()
++ if (testFile.getTotalSpace() != 0L)
++ throw new RuntimeException("The total space should be 0L");
++ // getFreeSpace()
++ if (testFile.getFreeSpace() != 0L)
++ throw new RuntimeException("The free space should be 0L");
++ // getUsableSpace()
++ if (testFile.getUsableSpace() != 0L)
++ throw new RuntimeException("The usable space should be 0L");
++ // compareTo(File null)
++ try {
++ exceptionThrown = false;
++ testFile.compareTo(null);
++ } catch (NullPointerException ex) {
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("compareTo(null) should throw NPE");
++ }
++ // toString()
++ if (testFile.toString().indexOf(CHAR_NUL) < 0) {
++ throw new RuntimeException(
++ "File path should contain Nul character");
++ }
++ // toPath()
++ try {
++ exceptionThrown = false;
++ testFile.toPath();
++ } catch (InvalidPathException ex) {
++ exceptionThrown = true;
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("toPath() should throw"
++ + " InvalidPathException");
++ }
++ }
++
++ private static void testSerialization(File testFile) {
++ String path = testFile.getPath();
++ try {
++ // serialize test file
++ ByteArrayOutputStream baos = new ByteArrayOutputStream();
++ ObjectOutputStream oos = new ObjectOutputStream(baos);
++ oos.writeObject(testFile);
++ oos.close();
++ // deserialize test file
++ byte[] bytes = baos.toByteArray();
++ ByteArrayInputStream is = new ByteArrayInputStream(bytes);
++ ObjectInputStream ois = new ObjectInputStream(is);
++ File newFile = (File) ois.readObject();
++ // test
++ String newPath = newFile.getPath();
++ if (!path.equals(newPath)) {
++ throw new RuntimeException(
++ "Serialization should not change file path");
++ }
++ test(newFile, false);
++ } catch (IOException | ClassNotFoundException ex) {
++ System.err.println("Exception happens in testSerialization");
++ System.err.println(ex.getMessage());
++ }
++ }
++
++ private static void testTempFile() {
++ final String[] names = {"x", "xx", "xxx", "xxxx"};
++ final String shortPrefix = "sp";
++ final String prefix = "prefix";
++ final String suffix = "suffix";
++ File tmpDir = new File("tmpDir");
++
++ for (String name : names) {
++ int length = name.length();
++ for (int i = 0; i <= length; i++) {
++ StringBuilder sbName = new StringBuilder(name);
++ sbName.insert(i, CHAR_NUL);
++ String curName = sbName.toString();
++
++ // test prefix
++ testCreateTempFile(curName, suffix, tmpDir);
++ // test suffix
++ testCreateTempFile(shortPrefix, curName, tmpDir);
++ testCreateTempFile(prefix, curName, tmpDir);
++ // test directory
++ testCreateTempFile(shortPrefix, suffix, new File(curName));
++ testCreateTempFile(prefix, suffix, new File(curName));
++ }
++ }
++ }
++
++ private static void testCreateTempFile(String prefix, String suffix,
++ File directory) {
++ // createTempFile(String prefix, String suffix, File directory)
++ boolean exceptionThrown = false;
++ boolean shortPrefix = (prefix.length() < 3);
++ if (shortPrefix) {
++ try {
++ File.createTempFile(prefix, suffix, directory);
++ } catch (IllegalArgumentException ex) {
++ if ("Prefix string too short".equals(ex.getMessage()))
++ exceptionThrown = true;
++ } catch (IOException ioe) {
++ System.err.println("IOException happens in testCreateTempFile");
++ System.err.println(ioe.getMessage());
++ }
++ } else {
++ try {
++ File.createTempFile(prefix, suffix, directory);
++ } catch (IOException ex) {
++ if ("Unable to create temporary file".equals(ex.getMessage()))
++ exceptionThrown = true;
++ }
++ }
++ if (!exceptionThrown) {
++ throw new RuntimeException("createTempFile() should throw"
++ + (shortPrefix ? " IllegalArgumentException"
++ : " IOException"));
++ }
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8004188-rename_java.security.patch b/java/openjdk6/files/icedtea/openjdk/8004188-rename_java.security.patch
new file mode 100644
index 000000000000..10209ee5ecd3
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8004188-rename_java.security.patch
@@ -0,0 +1,652 @@
+# HG changeset patch
+# User juh
+# Date 1382736906 -3600
+# Fri Oct 25 22:35:06 2013 +0100
+# Node ID 2a023db33371ce5ee42134cf0d860ab9f0adff92
+# Parent 3b6f55f02122398ba662fb581352c9c9b102c2e3
+8004188: Rename src/share/lib/security/java.security to java.security-linux
+Reviewed-by: mullan, mchung
+
+diff -r 3b6f55f02122 -r 2a023db33371 make/java/security/Makefile
+--- jdk/make/java/security/Makefile Fri Jul 12 11:36:15 2013 +0100
++++ jdk/make/java/security/Makefile Fri Oct 25 22:35:06 2013 +0100
+@@ -37,7 +37,8 @@
+ # Directories
+ #
+
+-PROPS_SRC = $(TOPDIR)/src/share/lib/security/java.security
++# The default security properties file is for linux
++PROPS_SRC = $(TOPDIR)/src/share/lib/security/java.security-linux
+ SUNPKCS11 =
+
+ ifeq ($(PLATFORM), solaris)
+diff -r 3b6f55f02122 -r 2a023db33371 src/share/lib/security/java.security
+--- jdk/src/share/lib/security/java.security Fri Jul 12 11:36:15 2013 +0100
++++ /dev/null Thu Jan 01 00:00:00 1970 +0000
+@@ -1,311 +0,0 @@
+-#
+-# This is the "master security properties file".
+-#
+-# In this file, various security properties are set for use by
+-# java.security classes. This is where users can statically register
+-# Cryptography Package Providers ("providers" for short). The term
+-# "provider" refers to a package or set of packages that supply a
+-# concrete implementation of a subset of the cryptography aspects of
+-# the Java Security API. A provider may, for example, implement one or
+-# more digital signature algorithms or message digest algorithms.
+-#
+-# Each provider must implement a subclass of the Provider class.
+-# To register a provider in this master security properties file,
+-# specify the Provider subclass name and priority in the format
+-#
+-# security.provider.<n>=<className>
+-#
+-# This declares a provider, and specifies its preference
+-# order n. The preference order is the order in which providers are
+-# searched for requested algorithms (when no specific provider is
+-# requested). The order is 1-based; 1 is the most preferred, followed
+-# by 2, and so on.
+-#
+-# <className> must specify the subclass of the Provider class whose
+-# constructor sets the values of various properties that are required
+-# for the Java Security API to look up the algorithms or other
+-# facilities implemented by the provider.
+-#
+-# There must be at least one provider specification in java.security.
+-# There is a default provider that comes standard with the JDK. It
+-# is called the "SUN" provider, and its Provider subclass
+-# named Sun appears in the sun.security.provider package. Thus, the
+-# "SUN" provider is registered via the following:
+-#
+-# security.provider.1=sun.security.provider.Sun
+-#
+-# (The number 1 is used for the default provider.)
+-#
+-# Note: Providers can be dynamically registered instead by calls to
+-# either the addProvider or insertProviderAt method in the Security
+-# class.
+-
+-#
+-# List of providers and their preference orders (see above):
+-#
+-security.provider.1=sun.security.provider.Sun
+-security.provider.2=sun.security.rsa.SunRsaSign
+-security.provider.3=com.sun.net.ssl.internal.ssl.Provider
+-security.provider.4=com.sun.crypto.provider.SunJCE
+-security.provider.5=sun.security.jgss.SunProvider
+-security.provider.6=com.sun.security.sasl.Provider
+-security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI
+-security.provider.8=sun.security.smartcardio.SunPCSC
+-
+-#
+-# Select the source of seed data for SecureRandom. By default an
+-# attempt is made to use the entropy gathering device specified by
+-# the securerandom.source property. If an exception occurs when
+-# accessing the URL then the traditional system/thread activity
+-# algorithm is used.
+-#
+-# On Solaris and Linux systems, if file:/dev/urandom is specified and it
+-# exists, a special SecureRandom implementation is activated by default.
+-# This "NativePRNG" reads random bytes directly from /dev/urandom.
+-#
+-# On Windows systems, the URLs file:/dev/random and file:/dev/urandom
+-# enables use of the Microsoft CryptoAPI seed functionality.
+-#
+-securerandom.source=file:/dev/urandom
+-#
+-# The entropy gathering device is described as a URL and can also
+-# be specified with the system property "java.security.egd". For example,
+-# -Djava.security.egd=file:/dev/urandom
+-# Specifying this system property will override the securerandom.source
+-# setting.
+-
+-#
+-# Class to instantiate as the javax.security.auth.login.Configuration
+-# provider.
+-#
+-login.configuration.provider=com.sun.security.auth.login.ConfigFile
+-
+-#
+-# Default login configuration file
+-#
+-#login.config.url.1=file:${user.home}/.java.login.config
+-
+-#
+-# Class to instantiate as the system Policy. This is the name of the class
+-# that will be used as the Policy object.
+-#
+-policy.provider=sun.security.provider.PolicyFile
+-
+-# The default is to have a single system-wide policy file,
+-# and a policy file in the user's home directory.
+-policy.url.1=file:${java.home}/lib/security/java.policy
+-policy.url.2=file:${user.home}/.java.policy
+-
+-# whether or not we expand properties in the policy file
+-# if this is set to false, properties (${...}) will not be expanded in policy
+-# files.
+-policy.expandProperties=true
+-
+-# whether or not we allow an extra policy to be passed on the command line
+-# with -Djava.security.policy=somefile. Comment out this line to disable
+-# this feature.
+-policy.allowSystemProperty=true
+-
+-# whether or not we look into the IdentityScope for trusted Identities
+-# when encountering a 1.1 signed JAR file. If the identity is found
+-# and is trusted, we grant it AllPermission.
+-policy.ignoreIdentityScope=false
+-
+-#
+-# Default keystore type.
+-#
+-keystore.type=jks
+-
+-#
+-# Class to instantiate as the system scope:
+-#
+-system.scope=sun.security.provider.IdentityDatabase
+-
+-#
+-# List of comma-separated packages that start with or equal this string
+-# will cause a security exception to be thrown when
+-# passed to checkPackageAccess unless the
+-# corresponding RuntimePermission ("accessClassInPackage."+package) has
+-# been granted.
+-package.access=sun.,\
+- com.sun.corba.se.impl.,\
+- com.sun.xml.internal.,\
+- com.sun.imageio.,\
+- com.sun.istack.internal.,\
+- com.sun.jmx.,\
+- com.sun.proxy.,\
+- com.sun.org.apache.bcel.internal.,\
+- com.sun.org.apache.regexp.internal.,\
+- com.sun.org.apache.xerces.internal.,\
+- com.sun.org.apache.xpath.internal.,\
+- com.sun.org.apache.xalan.internal.extensions.,\
+- com.sun.org.apache.xalan.internal.lib.,\
+- com.sun.org.apache.xalan.internal.res.,\
+- com.sun.org.apache.xalan.internal.templates.,\
+- com.sun.org.apache.xalan.internal.xslt.,\
+- com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
+- com.sun.org.apache.xalan.internal.xsltc.compiler.,\
+- com.sun.org.apache.xalan.internal.xsltc.trax.,\
+- com.sun.org.apache.xalan.internal.xsltc.util.,\
+- 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.
+-
+-#
+-# List of comma-separated packages that start with or equal this string
+-# will cause a security exception to be thrown when
+-# passed to checkPackageDefinition unless the
+-# corresponding RuntimePermission ("defineClassInPackage."+package) has
+-# been granted.
+-#
+-# by default, none of the class loaders supplied with the JDK call
+-# checkPackageDefinition.
+-#
+-package.definition=sun.,\
+- com.sun.corba.se.impl.,\
+- com.sun.xml.internal.,\
+- com.sun.imageio.,\
+- com.sun.istack.internal.,\
+- com.sun.jmx.,\
+- com.sun.proxy.,\
+- com.sun.org.apache.bcel.internal.,\
+- com.sun.org.apache.regexp.internal.,\
+- com.sun.org.apache.xerces.internal.,\
+- com.sun.org.apache.xpath.internal.,\
+- com.sun.org.apache.xalan.internal.extensions.,\
+- com.sun.org.apache.xalan.internal.lib.,\
+- com.sun.org.apache.xalan.internal.res.,\
+- com.sun.org.apache.xalan.internal.templates.,\
+- com.sun.org.apache.xalan.internal.xslt.,\
+- com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
+- com.sun.org.apache.xalan.internal.xsltc.compiler.,\
+- com.sun.org.apache.xalan.internal.xsltc.trax.,\
+- com.sun.org.apache.xalan.internal.xsltc.util.,\
+- 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.
+-
+-#
+-# Determines whether this properties file can be appended to
+-# or overridden on the command line via -Djava.security.properties
+-#
+-security.overridePropertiesFile=true
+-
+-#
+-# Determines the default key and trust manager factory algorithms for
+-# the javax.net.ssl package.
+-#
+-ssl.KeyManagerFactory.algorithm=SunX509
+-ssl.TrustManagerFactory.algorithm=PKIX
+-
+-#
+-# The Java-level namelookup cache policy for successful lookups:
+-#
+-# any negative value: caching forever
+-# any positive value: the number of seconds to cache an address for
+-# zero: do not cache
+-#
+-# default value is forever (FOREVER). For security reasons, this
+-# caching is made forever when a security manager is set. When a security
+-# manager is not set, the default behavior in this implementation
+-# is to cache for 30 seconds.
+-#
+-# NOTE: setting this to anything other than the default value can have
+-# serious security implications. Do not set it unless
+-# you are sure you are not exposed to DNS spoofing attack.
+-#
+-#networkaddress.cache.ttl=-1
+-
+-# The Java-level namelookup cache policy for failed lookups:
+-#
+-# any negative value: cache forever
+-# any positive value: the number of seconds to cache negative lookup results
+-# zero: do not cache
+-#
+-# In some Microsoft Windows networking environments that employ
+-# the WINS name service in addition to DNS, name service lookups
+-# that fail may take a noticeably long time to return (approx. 5 seconds).
+-# For this reason the default caching policy is to maintain these
+-# results for 10 seconds.
+-#
+-#
+-networkaddress.cache.negative.ttl=10
+-
+-#
+-# Properties to configure OCSP for certificate revocation checking
+-#
+-
+-# Enable OCSP
+-#
+-# By default, OCSP is not used for certificate revocation checking.
+-# This property enables the use of OCSP when set to the value "true".
+-#
+-# NOTE: SocketPermission is required to connect to an OCSP responder.
+-#
+-# Example,
+-# ocsp.enable=true
+-
+-#
+-# Location of the OCSP responder
+-#
+-# By default, the location of the OCSP responder is determined implicitly
+-# from the certificate being validated. This property explicitly specifies
+-# the location of the OCSP responder. The property is used when the
+-# Authority Information Access extension (defined in RFC 3280) is absent
+-# from the certificate or when it requires overriding.
+-#
+-# Example,
+-# ocsp.responderURL=http://ocsp.example.net:80
+-
+-#
+-# Subject name of the OCSP responder's certificate
+-#
+-# By default, the certificate of the OCSP responder is that of the issuer
+-# of the certificate being validated. This property identifies the certificate
+-# of the OCSP responder when the default does not apply. Its value is a string
+-# distinguished name (defined in RFC 2253) which identifies a certificate in
+-# the set of certificates supplied during cert path validation. In cases where
+-# the subject name alone is not sufficient to uniquely identify the certificate
+-# then both the "ocsp.responderCertIssuerName" and
+-# "ocsp.responderCertSerialNumber" properties must be used instead. When this
+-# property is set then those two properties are ignored.
+-#
+-# Example,
+-# ocsp.responderCertSubjectName="CN=OCSP Responder, O=XYZ Corp"
+-
+-#
+-# Issuer name of the OCSP responder's certificate
+-#
+-# By default, the certificate of the OCSP responder is that of the issuer
+-# of the certificate being validated. This property identifies the certificate
+-# of the OCSP responder when the default does not apply. Its value is a string
+-# distinguished name (defined in RFC 2253) which identifies a certificate in
+-# the set of certificates supplied during cert path validation. When this
+-# property is set then the "ocsp.responderCertSerialNumber" property must also
+-# be set. When the "ocsp.responderCertSubjectName" property is set then this
+-# property is ignored.
+-#
+-# Example,
+-# ocsp.responderCertIssuerName="CN=Enterprise CA, O=XYZ Corp"
+-
+-#
+-# Serial number of the OCSP responder's certificate
+-#
+-# By default, the certificate of the OCSP responder is that of the issuer
+-# of the certificate being validated. This property identifies the certificate
+-# of the OCSP responder when the default does not apply. Its value is a string
+-# of hexadecimal digits (colon or space separators may be present) which
+-# identifies a certificate in the set of certificates supplied during cert path
+-# validation. When this property is set then the "ocsp.responderCertIssuerName"
+-# property must also be set. When the "ocsp.responderCertSubjectName" property
+-# is set then this property is ignored.
+-#
+-# Example,
+-# ocsp.responderCertSerialNumber=2A:FF:00
+-
+diff -r 3b6f55f02122 -r 2a023db33371 src/share/lib/security/java.security-linux
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/src/share/lib/security/java.security-linux Fri Oct 25 22:35:06 2013 +0100
+@@ -0,0 +1,311 @@
++#
++# This is the "master security properties file".
++#
++# In this file, various security properties are set for use by
++# java.security classes. This is where users can statically register
++# Cryptography Package Providers ("providers" for short). The term
++# "provider" refers to a package or set of packages that supply a
++# concrete implementation of a subset of the cryptography aspects of
++# the Java Security API. A provider may, for example, implement one or
++# more digital signature algorithms or message digest algorithms.
++#
++# Each provider must implement a subclass of the Provider class.
++# To register a provider in this master security properties file,
++# specify the Provider subclass name and priority in the format
++#
++# security.provider.<n>=<className>
++#
++# This declares a provider, and specifies its preference
++# order n. The preference order is the order in which providers are
++# searched for requested algorithms (when no specific provider is
++# requested). The order is 1-based; 1 is the most preferred, followed
++# by 2, and so on.
++#
++# <className> must specify the subclass of the Provider class whose
++# constructor sets the values of various properties that are required
++# for the Java Security API to look up the algorithms or other
++# facilities implemented by the provider.
++#
++# There must be at least one provider specification in java.security.
++# There is a default provider that comes standard with the JDK. It
++# is called the "SUN" provider, and its Provider subclass
++# named Sun appears in the sun.security.provider package. Thus, the
++# "SUN" provider is registered via the following:
++#
++# security.provider.1=sun.security.provider.Sun
++#
++# (The number 1 is used for the default provider.)
++#
++# Note: Providers can be dynamically registered instead by calls to
++# either the addProvider or insertProviderAt method in the Security
++# class.
++
++#
++# List of providers and their preference orders (see above):
++#
++security.provider.1=sun.security.provider.Sun
++security.provider.2=sun.security.rsa.SunRsaSign
++security.provider.3=com.sun.net.ssl.internal.ssl.Provider
++security.provider.4=com.sun.crypto.provider.SunJCE
++security.provider.5=sun.security.jgss.SunProvider
++security.provider.6=com.sun.security.sasl.Provider
++security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI
++security.provider.8=sun.security.smartcardio.SunPCSC
++
++#
++# Select the source of seed data for SecureRandom. By default an
++# attempt is made to use the entropy gathering device specified by
++# the securerandom.source property. If an exception occurs when
++# accessing the URL then the traditional system/thread activity
++# algorithm is used.
++#
++# On Solaris and Linux systems, if file:/dev/urandom is specified and it
++# exists, a special SecureRandom implementation is activated by default.
++# This "NativePRNG" reads random bytes directly from /dev/urandom.
++#
++# On Windows systems, the URLs file:/dev/random and file:/dev/urandom
++# enables use of the Microsoft CryptoAPI seed functionality.
++#
++securerandom.source=file:/dev/urandom
++#
++# The entropy gathering device is described as a URL and can also
++# be specified with the system property "java.security.egd". For example,
++# -Djava.security.egd=file:/dev/urandom
++# Specifying this system property will override the securerandom.source
++# setting.
++
++#
++# Class to instantiate as the javax.security.auth.login.Configuration
++# provider.
++#
++login.configuration.provider=com.sun.security.auth.login.ConfigFile
++
++#
++# Default login configuration file
++#
++#login.config.url.1=file:${user.home}/.java.login.config
++
++#
++# Class to instantiate as the system Policy. This is the name of the class
++# that will be used as the Policy object.
++#
++policy.provider=sun.security.provider.PolicyFile
++
++# The default is to have a single system-wide policy file,
++# and a policy file in the user's home directory.
++policy.url.1=file:${java.home}/lib/security/java.policy
++policy.url.2=file:${user.home}/.java.policy
++
++# whether or not we expand properties in the policy file
++# if this is set to false, properties (${...}) will not be expanded in policy
++# files.
++policy.expandProperties=true
++
++# whether or not we allow an extra policy to be passed on the command line
++# with -Djava.security.policy=somefile. Comment out this line to disable
++# this feature.
++policy.allowSystemProperty=true
++
++# whether or not we look into the IdentityScope for trusted Identities
++# when encountering a 1.1 signed JAR file. If the identity is found
++# and is trusted, we grant it AllPermission.
++policy.ignoreIdentityScope=false
++
++#
++# Default keystore type.
++#
++keystore.type=jks
++
++#
++# Class to instantiate as the system scope:
++#
++system.scope=sun.security.provider.IdentityDatabase
++
++#
++# List of comma-separated packages that start with or equal this string
++# will cause a security exception to be thrown when
++# passed to checkPackageAccess unless the
++# corresponding RuntimePermission ("accessClassInPackage."+package) has
++# been granted.
++package.access=sun.,\
++ com.sun.corba.se.impl.,\
++ com.sun.xml.internal.,\
++ com.sun.imageio.,\
++ com.sun.istack.internal.,\
++ com.sun.jmx.,\
++ com.sun.proxy.,\
++ com.sun.org.apache.bcel.internal.,\
++ com.sun.org.apache.regexp.internal.,\
++ com.sun.org.apache.xerces.internal.,\
++ com.sun.org.apache.xpath.internal.,\
++ com.sun.org.apache.xalan.internal.extensions.,\
++ com.sun.org.apache.xalan.internal.lib.,\
++ com.sun.org.apache.xalan.internal.res.,\
++ com.sun.org.apache.xalan.internal.templates.,\
++ com.sun.org.apache.xalan.internal.xslt.,\
++ com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
++ com.sun.org.apache.xalan.internal.xsltc.compiler.,\
++ com.sun.org.apache.xalan.internal.xsltc.trax.,\
++ com.sun.org.apache.xalan.internal.xsltc.util.,\
++ 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.
++
++#
++# List of comma-separated packages that start with or equal this string
++# will cause a security exception to be thrown when
++# passed to checkPackageDefinition unless the
++# corresponding RuntimePermission ("defineClassInPackage."+package) has
++# been granted.
++#
++# by default, none of the class loaders supplied with the JDK call
++# checkPackageDefinition.
++#
++package.definition=sun.,\
++ com.sun.corba.se.impl.,\
++ com.sun.xml.internal.,\
++ com.sun.imageio.,\
++ com.sun.istack.internal.,\
++ com.sun.jmx.,\
++ com.sun.proxy.,\
++ com.sun.org.apache.bcel.internal.,\
++ com.sun.org.apache.regexp.internal.,\
++ com.sun.org.apache.xerces.internal.,\
++ com.sun.org.apache.xpath.internal.,\
++ com.sun.org.apache.xalan.internal.extensions.,\
++ com.sun.org.apache.xalan.internal.lib.,\
++ com.sun.org.apache.xalan.internal.res.,\
++ com.sun.org.apache.xalan.internal.templates.,\
++ com.sun.org.apache.xalan.internal.xslt.,\
++ com.sun.org.apache.xalan.internal.xsltc.cmdline.,\
++ com.sun.org.apache.xalan.internal.xsltc.compiler.,\
++ com.sun.org.apache.xalan.internal.xsltc.trax.,\
++ com.sun.org.apache.xalan.internal.xsltc.util.,\
++ 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.
++
++#
++# Determines whether this properties file can be appended to
++# or overridden on the command line via -Djava.security.properties
++#
++security.overridePropertiesFile=true
++
++#
++# Determines the default key and trust manager factory algorithms for
++# the javax.net.ssl package.
++#
++ssl.KeyManagerFactory.algorithm=SunX509
++ssl.TrustManagerFactory.algorithm=PKIX
++
++#
++# The Java-level namelookup cache policy for successful lookups:
++#
++# any negative value: caching forever
++# any positive value: the number of seconds to cache an address for
++# zero: do not cache
++#
++# default value is forever (FOREVER). For security reasons, this
++# caching is made forever when a security manager is set. When a security
++# manager is not set, the default behavior in this implementation
++# is to cache for 30 seconds.
++#
++# NOTE: setting this to anything other than the default value can have
++# serious security implications. Do not set it unless
++# you are sure you are not exposed to DNS spoofing attack.
++#
++#networkaddress.cache.ttl=-1
++
++# The Java-level namelookup cache policy for failed lookups:
++#
++# any negative value: cache forever
++# any positive value: the number of seconds to cache negative lookup results
++# zero: do not cache
++#
++# In some Microsoft Windows networking environments that employ
++# the WINS name service in addition to DNS, name service lookups
++# that fail may take a noticeably long time to return (approx. 5 seconds).
++# For this reason the default caching policy is to maintain these
++# results for 10 seconds.
++#
++#
++networkaddress.cache.negative.ttl=10
++
++#
++# Properties to configure OCSP for certificate revocation checking
++#
++
++# Enable OCSP
++#
++# By default, OCSP is not used for certificate revocation checking.
++# This property enables the use of OCSP when set to the value "true".
++#
++# NOTE: SocketPermission is required to connect to an OCSP responder.
++#
++# Example,
++# ocsp.enable=true
++
++#
++# Location of the OCSP responder
++#
++# By default, the location of the OCSP responder is determined implicitly
++# from the certificate being validated. This property explicitly specifies
++# the location of the OCSP responder. The property is used when the
++# Authority Information Access extension (defined in RFC 3280) is absent
++# from the certificate or when it requires overriding.
++#
++# Example,
++# ocsp.responderURL=http://ocsp.example.net:80
++
++#
++# Subject name of the OCSP responder's certificate
++#
++# By default, the certificate of the OCSP responder is that of the issuer
++# of the certificate being validated. This property identifies the certificate
++# of the OCSP responder when the default does not apply. Its value is a string
++# distinguished name (defined in RFC 2253) which identifies a certificate in
++# the set of certificates supplied during cert path validation. In cases where
++# the subject name alone is not sufficient to uniquely identify the certificate
++# then both the "ocsp.responderCertIssuerName" and
++# "ocsp.responderCertSerialNumber" properties must be used instead. When this
++# property is set then those two properties are ignored.
++#
++# Example,
++# ocsp.responderCertSubjectName="CN=OCSP Responder, O=XYZ Corp"
++
++#
++# Issuer name of the OCSP responder's certificate
++#
++# By default, the certificate of the OCSP responder is that of the issuer
++# of the certificate being validated. This property identifies the certificate
++# of the OCSP responder when the default does not apply. Its value is a string
++# distinguished name (defined in RFC 2253) which identifies a certificate in
++# the set of certificates supplied during cert path validation. When this
++# property is set then the "ocsp.responderCertSerialNumber" property must also
++# be set. When the "ocsp.responderCertSubjectName" property is set then this
++# property is ignored.
++#
++# Example,
++# ocsp.responderCertIssuerName="CN=Enterprise CA, O=XYZ Corp"
++
++#
++# Serial number of the OCSP responder's certificate
++#
++# By default, the certificate of the OCSP responder is that of the issuer
++# of the certificate being validated. This property identifies the certificate
++# of the OCSP responder when the default does not apply. Its value is a string
++# of hexadecimal digits (colon or space separators may be present) which
++# identifies a certificate in the set of certificates supplied during cert path
++# validation. When this property is set then the "ocsp.responderCertIssuerName"
++# property must also be set. When the "ocsp.responderCertSubjectName" property
++# is set then this property is ignored.
++#
++# Example,
++# ocsp.responderCertSerialNumber=2A:FF:00
++
diff --git a/java/openjdk6/files/icedtea/openjdk/8006882-jmockit.patch b/java/openjdk6/files/icedtea/openjdk/8006882-jmockit.patch
new file mode 100644
index 000000000000..9b96efe8072e
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8006882-jmockit.patch
@@ -0,0 +1,90 @@
+# HG changeset patch
+# User mchung
+# Date 1382735820 -3600
+# Fri Oct 25 22:17:00 2013 +0100
+# Node ID 695dd7ceb9e34fd4058374de63964c205f061002
+# Parent 5b485ecccea9064e5036e1bb040fc2af1f773c20
+8006882: Proxy generated classes in sun.proxy package breaks JMockit
+Reviewed-by: alanb, ahgross
+
+diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/classes/java/lang/reflect/Proxy.java
+--- jdk/src/share/classes/java/lang/reflect/Proxy.java Fri Oct 25 22:11:26 2013 +0100
++++ jdk/src/share/classes/java/lang/reflect/Proxy.java Fri Oct 25 22:17:00 2013 +0100
+@@ -609,7 +609,7 @@
+ }
+
+ if (proxyPkg == null) {
+- // if no non-public proxy interfaces, use sun.proxy package
++ // if no non-public proxy interfaces, use com.sun.proxy package
+ proxyPkg = ReflectUtil.PROXY_PACKAGE + ".";
+ }
+
+diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/classes/sun/reflect/misc/ReflectUtil.java
+--- jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Fri Oct 25 22:11:26 2013 +0100
++++ jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Fri Oct 25 22:17:00 2013 +0100
+@@ -246,7 +246,7 @@
+ }
+ }
+
+- public static final String PROXY_PACKAGE = "sun.proxy";
++ public static final String PROXY_PACKAGE = "com.sun.proxy";
+
+ /**
+ * Test if the given class is a proxy class that implements
+diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/lib/security/java.security
+--- jdk/src/share/lib/security/java.security Fri Oct 25 22:11:26 2013 +0100
++++ jdk/src/share/lib/security/java.security Fri Oct 25 22:17:00 2013 +0100
+@@ -132,6 +132,7 @@
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
++ com.sun.proxy.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+@@ -167,6 +168,7 @@
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
++ com.sun.proxy.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/lib/security/java.security-solaris
+--- jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:11:26 2013 +0100
++++ jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:17:00 2013 +0100
+@@ -133,6 +133,7 @@
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
++ com.sun.proxy.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+@@ -169,6 +170,7 @@
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
++ com.sun.proxy.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+diff -r 5b485ecccea9 -r 695dd7ceb9e3 src/share/lib/security/java.security-windows
+--- jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:11:26 2013 +0100
++++ jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:17:00 2013 +0100
+@@ -133,6 +133,7 @@
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
++ com.sun.proxy.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+@@ -170,6 +171,7 @@
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
++ com.sun.proxy.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
diff --git a/java/openjdk6/files/icedtea/openjdk/8006900-new_date_time.patch b/java/openjdk6/files/icedtea/openjdk/8006900-new_date_time.patch
new file mode 100644
index 000000000000..921197ef51c3
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8006900-new_date_time.patch
@@ -0,0 +1,115 @@
+# HG changeset patch
+# User okutsu
+# Date 1374215521 -32400
+# Fri Jul 19 15:32:01 2013 +0900
+# Node ID f38a3c5421df4697851a4b4d491071c3a30e5378
+# Parent 5d81a5f8a3791316367990b35b1ad5faef42d773
+8006900: Add new date/time capability
+Reviewed-by: mchung, hawtin
+
+diff -r 5d81a5f8a379 -r f38a3c5421df src/share/classes/java/util/TimeZone.java
+--- jdk/src/share/classes/java/util/TimeZone.java Tue Oct 15 15:04:24 2013 +0100
++++ jdk/src/share/classes/java/util/TimeZone.java Fri Jul 19 15:32:01 2013 +0900
+@@ -170,6 +170,11 @@
+ // Proclaim serialization compatibility with JDK 1.1
+ static final long serialVersionUID = 3581463369166924961L;
+
++ // TimeZone.setDefault maintains the compatible behavior of the AppContext-based
++ // default setting for untrusted code if allowSetDefault is true.
++ private static final boolean allowSetDefault = AccessController.doPrivileged(
++ new sun.security.action.GetPropertyAction("jdk.util.TimeZone.allowSetDefault")) != null;
++
+ /**
+ * Gets the time zone offset, for current date, modified in case of
+ * daylight savings. This is the offset to add to UTC to get local time.
+@@ -616,6 +621,9 @@
+ sm.checkPermission(new PropertyPermission
+ ("user.timezone", "write"));
+ } catch (SecurityException e) {
++ if (!allowSetDefault) {
++ throw e;
++ }
+ hasPermission = false;
+ }
+ }
+@@ -646,6 +654,7 @@
+ * Returns the default TimeZone in an AppContext if any AppContext
+ * has ever used. null is returned if any AppContext hasn't been
+ * used or if the AppContext doesn't have the default TimeZone.
++ * null is also returned if allowSetDefault is false.
+ *
+ * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
+ * been loaded. If so, it implies that AWTSecurityManager is not our
+@@ -653,18 +662,20 @@
+ * This works around a build time issue.
+ */
+ private static TimeZone getDefaultInAppContext() {
+- // JavaAWTAccess provides access implementation-private methods without using reflection.
+- JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+- if (javaAWTAccess == null) {
+- return mainAppContextDefault;
+- } else {
+- if (!javaAWTAccess.isDisposed()) {
+- TimeZone tz = (TimeZone)
+- javaAWTAccess.get(TimeZone.class);
+- if (tz == null && javaAWTAccess.isMainAppContext()) {
+- return mainAppContextDefault;
+- } else {
+- return tz;
++ if (allowSetDefault) {
++ // JavaAWTAccess provides access implementation-private methods without using reflection.
++ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
++ if (javaAWTAccess == null) {
++ return mainAppContextDefault;
++ } else {
++ if (!javaAWTAccess.isDisposed()) {
++ TimeZone tz = (TimeZone)
++ javaAWTAccess.get(TimeZone.class);
++ if (tz == null && javaAWTAccess.isMainAppContext()) {
++ return mainAppContextDefault;
++ } else {
++ return tz;
++ }
+ }
+ }
+ }
+@@ -672,9 +683,9 @@
+ }
+
+ /**
+- * Sets the default TimeZone in the AppContext to the given
+- * tz. null is handled special: do nothing if any AppContext
+- * hasn't been used, remove the default TimeZone in the
++ * Sets the default TimeZone in the AppContext to the given tz if
++ * allowSetDefault is true. null is handled special: do nothing if any
++ * AppContext hasn't been used, remove the default TimeZone in the
+ * AppContext otherwise.
+ *
+ * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
+@@ -683,15 +694,17 @@
+ * This works around a build time issue.
+ */
+ private static void setDefaultInAppContext(TimeZone tz) {
+- // JavaAWTAccess provides access implementation-private methods without using reflection.
+- JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+- if (javaAWTAccess == null) {
+- mainAppContextDefault = tz;
+- } else {
+- if (!javaAWTAccess.isDisposed()) {
+- javaAWTAccess.put(TimeZone.class, tz);
+- if (javaAWTAccess.isMainAppContext()) {
+- mainAppContextDefault = null;
++ if (allowSetDefault) {
++ // JavaAWTAccess provides access implementation-private methods without using reflection.
++ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
++ if (javaAWTAccess == null) {
++ mainAppContextDefault = tz;
++ } else {
++ if (!javaAWTAccess.isDisposed()) {
++ javaAWTAccess.put(TimeZone.class, tz);
++ if (javaAWTAccess.isMainAppContext()) {
++ mainAppContextDefault = null;
++ }
+ }
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8008589-better_mbean_permission_validation.patch b/java/openjdk6/files/icedtea/openjdk/8008589-better_mbean_permission_validation.patch
new file mode 100644
index 000000000000..32666f739a6e
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8008589-better_mbean_permission_validation.patch
@@ -0,0 +1,61 @@
+# HG changeset patch
+# User dsamersoff
+# Date 1373279676 -14400
+# Mon Jul 08 14:34:36 2013 +0400
+# Node ID db4712506571ae3ae2d37b91e63641b18c3258f2
+# Parent f38a3c5421df4697851a4b4d491071c3a30e5378
+8008589: Better MBean permission validation
+Summary: Better MBean permission validation
+Reviewed-by: skoivu, dfuchs, mchung, sjiang
+
+diff -r f38a3c5421df -r db4712506571 src/share/classes/javax/management/MBeanTrustPermission.java
+--- jdk/src/share/classes/javax/management/MBeanTrustPermission.java Fri Jul 19 15:32:01 2013 +0900
++++ jdk/src/share/classes/javax/management/MBeanTrustPermission.java Mon Jul 08 14:34:36 2013 +0400
+@@ -26,6 +26,9 @@
+ package javax.management;
+
+ import java.security.BasicPermission;
++import java.io.IOException;
++import java.io.InvalidObjectException;
++import java.io.ObjectInputStream;
+
+ /**
+ * This permission represents "trust" in a signer or codebase.
+@@ -75,15 +78,31 @@
+ */
+ public MBeanTrustPermission(String name, String actions) {
+ super(name, actions);
++ validate(name,actions);
++ }
++
++ private static void validate(String name, String actions) {
+ /* Check that actions is a null empty string */
+- if (actions != null && actions.length() > 0)
+- throw new IllegalArgumentException("MBeanTrustPermission " +
+- "actions must be null: " +
++ if (actions != null && actions.length() > 0) {
++ throw new IllegalArgumentException("MBeanTrustPermission actions must be null: " +
+ actions);
++ }
+
+- if (!name.equals("register") && !name.equals("*"))
+- throw new IllegalArgumentException("MBeanTrustPermission: " +
+- "Unknown target name " +
++ if (!name.equals("register") && !name.equals("*")) {
++ throw new IllegalArgumentException("MBeanTrustPermission: Unknown target name " +
+ "[" + name + "]");
++ }
++ }
++
++ private void readObject(ObjectInputStream in)
++ throws IOException, ClassNotFoundException {
++
++ // Reading private fields of base class
++ in.defaultReadObject();
++ try {
++ validate(super.getName(),super.getActions());
++ } catch (IllegalArgumentException e) {
++ throw new InvalidObjectException(e.getMessage());
++ }
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8010118-caller_sensitive.patch b/java/openjdk6/files/icedtea/openjdk/8010118-caller_sensitive.patch
new file mode 100644
index 000000000000..29ca05adfc00
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8010118-caller_sensitive.patch
@@ -0,0 +1,2968 @@
+# HG changeset patch
+# User mchung
+# Date 1382375156 -3600
+# Mon Oct 21 18:05:56 2013 +0100
+# Node ID d206cb658a9907c7842c8920f141b3c4eb5efc1f
+# Parent e56220b54fe2d0f09ee151b28d6e8495cea2136f
+8010118: Annotate jdk caller sensitive methods with @sun.reflect.CallerSensitive
+Reviewed-by: alanb, twisti, jrose, kvn
+
+diff -r e56220b54fe2 -r d206cb658a99 make/java/java/FILES_c.gmk
+--- jdk/make/java/java/FILES_c.gmk Wed Oct 16 05:39:53 2013 +0100
++++ jdk/make/java/java/FILES_c.gmk Mon Oct 21 18:05:56 2013 +0100
+@@ -48,7 +48,6 @@
+ Proxy.c \
+ RandomAccessFile.c \
+ RandomAccessFile_md.c \
+- ResourceBundle.c \
+ Runtime.c \
+ SecurityManager.c \
+ Shutdown.c \
+@@ -68,7 +67,6 @@
+ jdk_util_md.c \
+ check_version.c \
+ java_props_md.c \
+- DriverManager.c \
+ ConstantPool.c \
+ MessageUtils.c \
+ GC.c \
+diff -r e56220b54fe2 -r d206cb658a99 make/java/java/mapfile-vers
+--- jdk/make/java/java/mapfile-vers Wed Oct 16 05:39:53 2013 +0100
++++ jdk/make/java/java/mapfile-vers Mon Oct 21 18:05:56 2013 +0100
+@@ -237,8 +237,6 @@
+ Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2Ljava_security_AccessControlContext_2;
+ Java_java_security_AccessController_getStackAccessControlContext;
+ Java_java_security_AccessController_getInheritedAccessControlContext;
+- Java_java_sql_DriverManager_getCallerClassLoader;
+- Java_java_util_ResourceBundle_getClassContext;
+ Java_java_util_TimeZone_getSystemTimeZoneID;
+ Java_java_util_TimeZone_getSystemGMTOffsetID;
+ Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8;
+diff -r e56220b54fe2 -r d206cb658a99 make/java/java/reorder-i586
+--- jdk/make/java/java/reorder-i586 Wed Oct 16 05:39:53 2013 +0100
++++ jdk/make/java/java/reorder-i586 Mon Oct 21 18:05:56 2013 +0100
+@@ -73,7 +73,6 @@
+ # Test Sleep
+ # Test IntToString
+ # Test LoadToolkit
+-text: .text%Java_java_util_ResourceBundle_getClassContext;
+ text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2;
+ text: .text%JNU_GetEnv;
+ text: .text%Java_java_io_UnixFileSystem_checkAccess;
+diff -r e56220b54fe2 -r d206cb658a99 make/java/java/reorder-sparc
+--- jdk/make/java/java/reorder-sparc Wed Oct 16 05:39:53 2013 +0100
++++ jdk/make/java/java/reorder-sparc Mon Oct 21 18:05:56 2013 +0100
+@@ -78,7 +78,6 @@
+ # Test Sleep
+ # Test IntToString
+ # Test LoadToolkit
+-text: .text%Java_java_util_ResourceBundle_getClassContext;
+ text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2;
+ text: .text%JNU_GetEnv;
+ text: .text%Java_java_io_UnixFileSystem_checkAccess;
+diff -r e56220b54fe2 -r d206cb658a99 make/java/java/reorder-sparcv9
+--- jdk/make/java/java/reorder-sparcv9 Wed Oct 16 05:39:53 2013 +0100
++++ jdk/make/java/java/reorder-sparcv9 Mon Oct 21 18:05:56 2013 +0100
+@@ -74,7 +74,6 @@
+ # Test Sleep
+ # Test IntToString
+ # Test LoadToolkit
+-text: .text%Java_java_util_ResourceBundle_getClassContext;
+ text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2;
+ text: .text%JNU_GetEnv;
+ text: .text%Java_java_io_UnixFileSystem_checkAccess;
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/io/ObjectStreamClass.java
+--- jdk/src/share/classes/java/io/ObjectStreamClass.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/io/ObjectStreamClass.java Mon Oct 21 18:05:56 2013 +0100
+@@ -49,6 +49,8 @@
+ import java.util.concurrent.ConcurrentHashMap;
+ import java.util.concurrent.ConcurrentMap;
+ import sun.misc.Unsafe;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+ import sun.reflect.ReflectionFactory;
+ import sun.reflect.misc.ReflectUtil;
+
+@@ -234,12 +236,13 @@
+ *
+ * @return the <code>Class</code> instance that this descriptor represents
+ */
++ @CallerSensitive
+ public Class<?> forClass() {
+ if (cl == null) {
+ return null;
+ }
+- ClassLoader ccl = ObjectStreamField.getCallerClassLoader();
+- if (ReflectUtil.needsPackageAccessCheck(ccl, cl.getClassLoader())) {
++ Class<?> caller = Reflection.getCallerClass();
++ if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) {
+ ReflectUtil.checkPackageAccess(cl);
+ }
+ return cl;
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/io/ObjectStreamField.java
+--- jdk/src/share/classes/java/io/ObjectStreamField.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/io/ObjectStreamField.java Mon Oct 21 18:05:56 2013 +0100
+@@ -26,6 +26,7 @@
+ package java.io;
+
+ import java.lang.reflect.Field;
++import sun.reflect.CallerSensitive;
+ import sun.reflect.Reflection;
+ import sun.reflect.misc.ReflectUtil;
+
+@@ -159,32 +160,15 @@
+ * @return a <code>Class</code> object representing the type of the
+ * serializable field
+ */
++ @CallerSensitive
+ public Class<?> getType() {
+- ClassLoader ccl = getCallerClassLoader();
+- if (ReflectUtil.needsPackageAccessCheck(ccl, type.getClassLoader())) {
++ Class<?> caller = Reflection.getCallerClass();
++ if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), 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>
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/Class.java
+--- jdk/src/share/classes/java/lang/Class.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/Class.java Mon Oct 21 18:05:56 2013 +0100
+@@ -53,6 +53,7 @@
+ import java.util.Map;
+ import java.util.HashMap;
+ import sun.misc.Unsafe;
++import sun.reflect.CallerSensitive;
+ import sun.reflect.ConstantPool;
+ import sun.reflect.Reflection;
+ import sun.reflect.ReflectionFactory;
+@@ -183,9 +184,11 @@
+ * by this method fails
+ * @exception ClassNotFoundException if the class cannot be located
+ */
++ @CallerSensitive
+ public static Class<?> forName(String className)
+ throws ClassNotFoundException {
+- return forName0(className, true, ClassLoader.getCallerClassLoader());
++ return forName0(className, true,
++ ClassLoader.getClassLoader(Reflection.getCallerClass()));
+ }
+
+
+@@ -249,6 +252,7 @@
+ * @see java.lang.ClassLoader
+ * @since 1.2
+ */
++ @CallerSensitive
+ public static Class<?> forName(String name, boolean initialize,
+ ClassLoader loader)
+ throws ClassNotFoundException
+@@ -256,7 +260,7 @@
+ if (loader == null) {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+- ClassLoader ccl = ClassLoader.getCallerClassLoader();
++ ClassLoader ccl = ClassLoader.getClassLoader(Reflection.getCallerClass());
+ if (ccl != null) {
+ sm.checkPermission(
+ SecurityConstants.GET_CLASSLOADER_PERMISSION);
+@@ -318,18 +322,14 @@
+ * </ul>
+ *
+ */
++ @CallerSensitive
+ public T newInstance()
+ throws InstantiationException, IllegalAccessException
+ {
+ if (System.getSecurityManager() != null) {
+- checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), false);
++ checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), false);
+ }
+- return newInstance0();
+- }
+
+- private T newInstance0()
+- throws InstantiationException, IllegalAccessException
+- {
+ // NOTE: the following code may not be strictly correct under
+ // the current Java memory model.
+
+@@ -363,7 +363,7 @@
+ // Security check (same as in java.lang.reflect.Constructor)
+ int modifiers = tmpConstructor.getModifiers();
+ if (!Reflection.quickCheckMemberAccess(this, modifiers)) {
+- Class caller = Reflection.getCallerClass(3);
++ Class<?> caller = Reflection.getCallerClass();
+ if (newInstanceCallerCache != caller) {
+ Reflection.ensureMemberAccess(caller, this, null, modifiers);
+ newInstanceCallerCache = caller;
+@@ -602,16 +602,14 @@
+ * @see SecurityManager#checkPermission
+ * @see java.lang.RuntimePermission
+ */
++ @CallerSensitive
+ public ClassLoader getClassLoader() {
+ ClassLoader cl = getClassLoader0();
+ if (cl == null)
+ return null;
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+- ClassLoader ccl = ClassLoader.getCallerClassLoader();
+- if (ccl != null && ccl != cl && !cl.isAncestor(ccl)) {
+- sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+- }
++ ClassLoader.checkClassLoaderPermission(cl, Reflection.getCallerClass());
+ }
+ return cl;
+ }
+@@ -891,6 +889,7 @@
+ * that class is a local or anonymous class; otherwise {@code null}.
+ * @since 1.5
+ */
++ @CallerSensitive
+ public Method getEnclosingMethod() {
+ EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo();
+
+@@ -920,7 +919,7 @@
+ //
+ // Note that we need to do this on the enclosing class
+ enclosingCandidate.checkMemberAccess(Member.DECLARED,
+- ClassLoader.getCallerClassLoader(), true);
++ Reflection.getCallerClass(), true);
+ /*
+ * Loop over all declared methods; match method name,
+ * number of and type of parameters, *and* return
+@@ -1028,6 +1027,7 @@
+ * that class is a local or anonymous class; otherwise {@code null}.
+ * @since 1.5
+ */
++ @CallerSensitive
+ public Constructor<?> getEnclosingConstructor() {
+ EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo();
+
+@@ -1056,7 +1056,7 @@
+ //
+ // Note that we need to do this on the enclosing class
+ enclosingCandidate.checkMemberAccess(Member.DECLARED,
+- ClassLoader.getCallerClassLoader(), true);
++ Reflection.getCallerClass(), true);
+ /*
+ * Loop over all declared constructors; match number
+ * of and type of parameters.
+@@ -1103,6 +1103,7 @@
+ * @return the immediately enclosing class of the underlying class
+ * @since 1.5
+ */
++ @CallerSensitive
+ public Class<?> getEnclosingClass() {
+ // There are five kinds of classes (or interfaces):
+ // a) Top level classes
+@@ -1135,7 +1136,7 @@
+ // see java.lang.SecurityManager.checkMemberAccess
+ if (enclosingCandidate != null) {
+ enclosingCandidate.checkMemberAccess(Member.DECLARED,
+- ClassLoader.getCallerClassLoader(), true);
++ Reflection.getCallerClass(), true);
+ }
+ return enclosingCandidate;
+ }
+@@ -1320,11 +1321,12 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Class<?>[] getClasses() {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), false);
++ checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), false);
+
+ // Privileged so this implementation can look at DECLARED classes,
+ // something the caller might not have privilege to do. The code here
+@@ -1398,11 +1400,12 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Field[] getFields() throws SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+ return copyFields(privateGetPublicFields(null));
+ }
+
+@@ -1449,11 +1452,12 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Method[] getMethods() throws SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+ return copyMethods(privateGetPublicMethods());
+ }
+
+@@ -1498,11 +1502,12 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Constructor<?>[] getConstructors() throws SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+ return copyConstructors(privateGetDeclaredConstructors(true));
+ }
+
+@@ -1556,12 +1561,13 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Field getField(String name)
+ throws NoSuchFieldException, SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+ Field field = getField0(name);
+ if (field == null) {
+ throw new NoSuchFieldException(name);
+@@ -1641,12 +1647,13 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Method getMethod(String name, Class<?>... parameterTypes)
+ throws NoSuchMethodException, SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+ Method method = getMethod0(name, parameterTypes);
+ if (method == null) {
+ throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes));
+@@ -1695,12 +1702,13 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Constructor<T> getConstructor(Class<?>... parameterTypes)
+ throws NoSuchMethodException, SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
+ return getConstructor0(parameterTypes, Member.PUBLIC);
+ }
+
+@@ -1738,11 +1746,12 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Class<?>[] getDeclaredClasses() throws SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), false);
++ checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), false);
+ return getDeclaredClasses0();
+ }
+
+@@ -1782,11 +1791,12 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Field[] getDeclaredFields() throws SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+ return copyFields(privateGetDeclaredFields(false));
+ }
+
+@@ -1830,11 +1840,12 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Method[] getDeclaredMethods() throws SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+ return copyMethods(privateGetDeclaredMethods(false));
+ }
+
+@@ -1875,11 +1886,12 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Constructor<?>[] getDeclaredConstructors() throws SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+ return copyConstructors(privateGetDeclaredConstructors(false));
+ }
+
+@@ -1918,12 +1930,13 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Field getDeclaredField(String name)
+ throws NoSuchFieldException, SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+ Field field = searchFields(privateGetDeclaredFields(false), name);
+ if (field == null) {
+ throw new NoSuchFieldException(name);
+@@ -1973,12 +1986,13 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
+ throws NoSuchMethodException, SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+ Method method = searchMethods(privateGetDeclaredMethods(false), name, parameterTypes);
+ if (method == null) {
+ throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes));
+@@ -2023,12 +2037,13 @@
+ *
+ * @since JDK1.1
+ */
++ @CallerSensitive
+ public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
+ throws NoSuchMethodException, SecurityException {
+ // be very careful not to change the stack depth of this
+ // checkMemberAccess call for security reasons
+ // see java.lang.SecurityManager.checkMemberAccess
+- checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true);
++ checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
+ return getConstructor0(parameterTypes, Member.DECLARED);
+ }
+
+@@ -2186,23 +2201,40 @@
+ */
+ static native Class getPrimitiveClass(String name);
+
++ private static boolean isCheckMemberAccessOverridden(SecurityManager smgr) {
++ if (smgr.getClass() == SecurityManager.class) return false;
++
++ Class<?>[] paramTypes = new Class<?>[] {Class.class, int.class};
++ return smgr.getClass().getMethod0("checkMemberAccess", paramTypes).
++ getDeclaringClass() != SecurityManager.class;
++ }
++
+
+ /*
+ * Check if client is allowed to access members. If access is denied,
+ * throw a SecurityException.
+ *
+- * Be very careful not to change the stack depth of this checkMemberAccess
+- * call for security reasons.
+- * See java.lang.SecurityManager.checkMemberAccess.
+- *
+ * <p> Default policy: allow all clients access with normal Java access
+ * control.
+ */
+- private void checkMemberAccess(int which, ClassLoader ccl, boolean checkProxyInterfaces) {
+- SecurityManager s = System.getSecurityManager();
++ private void checkMemberAccess(int which, Class<?> caller, boolean checkProxyInterfaces) {
++ final SecurityManager s = System.getSecurityManager();
+ if (s != null) {
+- s.checkMemberAccess(this, which);
+- ClassLoader cl = getClassLoader0();
++ final ClassLoader ccl = ClassLoader.getClassLoader(caller);
++ final ClassLoader cl = getClassLoader0();
++ if (!isCheckMemberAccessOverridden(s)) {
++ // Inlined SecurityManager.checkMemberAccess
++ if (which != Member.PUBLIC) {
++ if (ccl != cl) {
++ s.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
++ }
++ }
++ } else {
++ // Don't refactor; otherwise break the stack depth for
++ // checkMemberAccess of subclasses of SecurityManager as specified.
++ s.checkMemberAccess(this, which);
++ }
++
+ if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
+
+ String name = this.getName();
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/ClassLoader.java
+--- jdk/src/share/classes/java/lang/ClassLoader.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/ClassLoader.java Mon Oct 21 18:05:56 2013 +0100
+@@ -52,6 +52,7 @@
+ import sun.misc.Resource;
+ import sun.misc.URLClassPath;
+ import sun.misc.VM;
++import sun.reflect.CallerSensitive;
+ import sun.reflect.Reflection;
+ import sun.security.util.SecurityConstants;
+
+@@ -1214,15 +1215,13 @@
+ *
+ * @since 1.2
+ */
++ @CallerSensitive
+ public final ClassLoader getParent() {
+ if (parent == null)
+ return null;
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+- ClassLoader ccl = getCallerClassLoader();
+- if (ccl != null && !isAncestor(ccl)) {
+- sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+- }
++ checkClassLoaderPermission(parent, Reflection.getCallerClass());
+ }
+ return parent;
+ }
+@@ -1282,6 +1281,7 @@
+ *
+ * @revised 1.4
+ */
++ @CallerSensitive
+ public static ClassLoader getSystemClassLoader() {
+ initSystemClassLoader();
+ if (scl == null) {
+@@ -1289,10 +1289,7 @@
+ }
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+- ClassLoader ccl = getCallerClassLoader();
+- if (ccl != null && ccl != scl && !scl.isAncestor(ccl)) {
+- sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+- }
++ checkClassLoaderPermission(scl, Reflection.getCallerClass());
+ }
+ return scl;
+ }
+@@ -1341,13 +1338,25 @@
+ return false;
+ }
+
+- // Returns the invoker's class loader, or null if none.
+- // 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.
+- static ClassLoader getCallerClassLoader() {
+- // NOTE use of more generic Reflection.getCallerClass()
+- Class caller = Reflection.getCallerClass(3);
++ // Tests if class loader access requires "getClassLoader" permission
++ // check. A class loader 'from' can access class loader 'to' if
++ // class loader 'from' is same as class loader 'to' or an ancestor
++ // of 'to'. The class loader in a system domain can access
++ // any class loader.
++ private static boolean needsClassLoaderPermissionCheck(ClassLoader from,
++ ClassLoader to)
++ {
++ if (from == to)
++ return false;
++
++ if (from == null)
++ return false;
++
++ return !to.isAncestor(from);
++ }
++
++ // Returns the class's class loader, or null if none.
++ static ClassLoader getClassLoader(Class<?> caller) {
+ // This can be null if the VM is requesting it
+ if (caller == null) {
+ return null;
+@@ -1356,6 +1365,17 @@
+ return caller.getClassLoader0();
+ }
+
++ static void checkClassLoaderPermission(ClassLoader cl, Class<?> caller) {
++ SecurityManager sm = System.getSecurityManager();
++ if (sm != null) {
++ // caller can be null if the VM is requesting it
++ ClassLoader ccl = getClassLoader(caller);
++ if (needsClassLoaderPermissionCheck(ccl, cl)) {
++ sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
++ }
++ }
++ }
++
+ // The class loader for the system
+ private static ClassLoader scl;
+
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/Package.java
+--- jdk/src/share/classes/java/lang/Package.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/Package.java Mon Oct 21 18:05:56 2013 +0100
+@@ -47,9 +47,10 @@
+ import java.util.HashMap;
+ import java.util.Iterator;
+
++import java.lang.annotation.Annotation;
+ import sun.net.www.ParseUtil;
+-
+-import java.lang.annotation.Annotation;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+
+ /**
+ * {@code Package} objects contain version information
+@@ -273,8 +274,9 @@
+ * @return the package of the requested name. It may be null if no package
+ * information is available from the archive or codebase.
+ */
++ @CallerSensitive
+ public static Package getPackage(String name) {
+- ClassLoader l = ClassLoader.getCallerClassLoader();
++ ClassLoader l = ClassLoader.getClassLoader(Reflection.getCallerClass());
+ if (l != null) {
+ return l.getPackage(name);
+ } else {
+@@ -294,8 +296,9 @@
+ * @return a new array of packages known to the callers {@code ClassLoader}
+ * instance. An zero length array is returned if none are known.
+ */
++ @CallerSensitive
+ public static Package[] getPackages() {
+- ClassLoader l = ClassLoader.getCallerClassLoader();
++ ClassLoader l = ClassLoader.getClassLoader(Reflection.getCallerClass());
+ if (l != null) {
+ return l.getPackages();
+ } else {
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/Runtime.java
+--- jdk/src/share/classes/java/lang/Runtime.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/Runtime.java Mon Oct 21 18:05:56 2013 +0100
+@@ -27,6 +27,8 @@
+
+ import java.io.*;
+ import java.util.StringTokenizer;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+
+ /**
+ * Every Java application has a single instance of class
+@@ -771,8 +773,9 @@
+ * @see java.lang.SecurityException
+ * @see java.lang.SecurityManager#checkLink(java.lang.String)
+ */
++ @CallerSensitive
+ public void load(String filename) {
+- load0(System.getCallerClass(), filename);
++ load0(Reflection.getCallerClass(), filename);
+ }
+
+ synchronized void load0(Class fromClass, String filename) {
+@@ -824,8 +827,9 @@
+ * @see java.lang.SecurityException
+ * @see java.lang.SecurityManager#checkLink(java.lang.String)
+ */
++ @CallerSensitive
+ public void loadLibrary(String libname) {
+- loadLibrary0(System.getCallerClass(), libname);
++ loadLibrary0(Reflection.getCallerClass(), libname);
+ }
+
+ synchronized void loadLibrary0(Class fromClass, String libname) {
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/System.java
+--- jdk/src/share/classes/java/lang/System.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/System.java Mon Oct 21 18:05:56 2013 +0100
+@@ -35,6 +35,7 @@
+ import java.nio.channels.spi.SelectorProvider;
+ import sun.nio.ch.Interruptible;
+ import sun.net.InetAddressCachePolicy;
++import sun.reflect.CallerSensitive;
+ import sun.reflect.Reflection;
+ import sun.security.util.SecurityConstants;
+ import sun.reflect.annotation.AnnotationType;
+@@ -1018,8 +1019,9 @@
+ * @see java.lang.Runtime#load(java.lang.String)
+ * @see java.lang.SecurityManager#checkLink(java.lang.String)
+ */
++ @CallerSensitive
+ public static void load(String filename) {
+- Runtime.getRuntime().load0(getCallerClass(), filename);
++ Runtime.getRuntime().load0(Reflection.getCallerClass(), filename);
+ }
+
+ /**
+@@ -1043,8 +1045,9 @@
+ * @see java.lang.Runtime#loadLibrary(java.lang.String)
+ * @see java.lang.SecurityManager#checkLink(java.lang.String)
+ */
++ @CallerSensitive
+ public static void loadLibrary(String libname) {
+- Runtime.getRuntime().loadLibrary0(getCallerClass(), libname);
++ Runtime.getRuntime().loadLibrary0(Reflection.getCallerClass(), libname);
+ }
+
+ /**
+@@ -1157,10 +1160,4 @@
+ }
+ });
+ }
+-
+- /* returns the class of the caller. */
+- static Class getCallerClass() {
+- // NOTE use of more generic Reflection.getCallerClass()
+- return Reflection.getCallerClass(3);
+- }
+ }
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/Thread.java
+--- jdk/src/share/classes/java/lang/Thread.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/Thread.java Mon Oct 21 18:05:56 2013 +0100
+@@ -34,6 +34,8 @@
+ import java.util.concurrent.locks.LockSupport;
+ import sun.misc.SoftCache;
+ import sun.nio.ch.Interruptible;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+ import sun.security.util.SecurityConstants;
+
+
+@@ -1370,16 +1372,15 @@
+ *
+ * @since 1.2
+ */
++ @CallerSensitive
+ public ClassLoader getContextClassLoader() {
+ if (contextClassLoader == null)
+ return null;
++
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+- ClassLoader ccl = ClassLoader.getCallerClassLoader();
+- if (ccl != null && ccl != contextClassLoader &&
+- !contextClassLoader.isAncestor(ccl)) {
+- sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+- }
++ ClassLoader.checkClassLoaderPermission(contextClassLoader,
++ Reflection.getCallerClass());
+ }
+ return contextClassLoader;
+ }
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/reflect/Constructor.java
+--- jdk/src/share/classes/java/lang/reflect/Constructor.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/reflect/Constructor.java Mon Oct 21 18:05:56 2013 +0100
+@@ -25,6 +25,7 @@
+
+ package java.lang.reflect;
+
++import sun.reflect.CallerSensitive;
+ import sun.reflect.ConstructorAccessor;
+ import sun.reflect.Reflection;
+ import sun.reflect.generics.repository.ConstructorRepository;
+@@ -513,13 +514,14 @@
+ * @exception ExceptionInInitializerError if the initialization provoked
+ * by this method fails.
+ */
++ @CallerSensitive
+ public T newInstance(Object ... initargs)
+ throws InstantiationException, IllegalAccessException,
+ IllegalArgumentException, InvocationTargetException
+ {
+ if (!override) {
+ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
+- Class caller = Reflection.getCallerClass(2);
++ Class<?> caller = Reflection.getCallerClass();
+ if (securityCheckCache != caller) {
+ Reflection.ensureMemberAccess(caller, clazz, null, modifiers);
+ securityCheckCache = caller;
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/reflect/Field.java
+--- jdk/src/share/classes/java/lang/reflect/Field.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/reflect/Field.java Mon Oct 21 18:05:56 2013 +0100
+@@ -25,6 +25,7 @@
+
+ package java.lang.reflect;
+
++import sun.reflect.CallerSensitive;
+ import sun.reflect.FieldAccessor;
+ import sun.reflect.Reflection;
+ import sun.reflect.generics.repository.FieldRepository;
+@@ -370,9 +371,15 @@
+ * @exception ExceptionInInitializerError if the initialization provoked
+ * by this method fails.
+ */
++ @CallerSensitive
+ public Object get(Object obj)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ return getFieldAccessor(obj).get(obj);
+ }
+
+@@ -397,9 +404,15 @@
+ * by this method fails.
+ * @see Field#get
+ */
++ @CallerSensitive
+ public boolean getBoolean(Object obj)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ return getFieldAccessor(obj).getBoolean(obj);
+ }
+
+@@ -424,9 +437,15 @@
+ * by this method fails.
+ * @see Field#get
+ */
++ @CallerSensitive
+ public byte getByte(Object obj)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ return getFieldAccessor(obj).getByte(obj);
+ }
+
+@@ -453,9 +472,15 @@
+ * by this method fails.
+ * @see Field#get
+ */
++ @CallerSensitive
+ public char getChar(Object obj)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ return getFieldAccessor(obj).getChar(obj);
+ }
+
+@@ -482,9 +507,15 @@
+ * by this method fails.
+ * @see Field#get
+ */
++ @CallerSensitive
+ public short getShort(Object obj)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ return getFieldAccessor(obj).getShort(obj);
+ }
+
+@@ -511,9 +542,15 @@
+ * by this method fails.
+ * @see Field#get
+ */
++ @CallerSensitive
+ public int getInt(Object obj)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ return getFieldAccessor(obj).getInt(obj);
+ }
+
+@@ -540,9 +577,15 @@
+ * by this method fails.
+ * @see Field#get
+ */
++ @CallerSensitive
+ public long getLong(Object obj)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ return getFieldAccessor(obj).getLong(obj);
+ }
+
+@@ -569,9 +612,15 @@
+ * by this method fails.
+ * @see Field#get
+ */
++ @CallerSensitive
+ public float getFloat(Object obj)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ return getFieldAccessor(obj).getFloat(obj);
+ }
+
+@@ -598,9 +647,15 @@
+ * by this method fails.
+ * @see Field#get
+ */
++ @CallerSensitive
+ public double getDouble(Object obj)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ return getFieldAccessor(obj).getDouble(obj);
+ }
+
+@@ -669,9 +724,15 @@
+ * @exception ExceptionInInitializerError if the initialization provoked
+ * by this method fails.
+ */
++ @CallerSensitive
+ public void set(Object obj, Object value)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ getFieldAccessor(obj).set(obj, value);
+ }
+
+@@ -698,9 +759,15 @@
+ * by this method fails.
+ * @see Field#set
+ */
++ @CallerSensitive
+ public void setBoolean(Object obj, boolean z)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ getFieldAccessor(obj).setBoolean(obj, z);
+ }
+
+@@ -727,9 +794,15 @@
+ * by this method fails.
+ * @see Field#set
+ */
++ @CallerSensitive
+ public void setByte(Object obj, byte b)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ getFieldAccessor(obj).setByte(obj, b);
+ }
+
+@@ -756,9 +829,15 @@
+ * by this method fails.
+ * @see Field#set
+ */
++ @CallerSensitive
+ public void setChar(Object obj, char c)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ getFieldAccessor(obj).setChar(obj, c);
+ }
+
+@@ -785,9 +864,15 @@
+ * by this method fails.
+ * @see Field#set
+ */
++ @CallerSensitive
+ public void setShort(Object obj, short s)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ getFieldAccessor(obj).setShort(obj, s);
+ }
+
+@@ -814,9 +899,15 @@
+ * by this method fails.
+ * @see Field#set
+ */
++ @CallerSensitive
+ public void setInt(Object obj, int i)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ getFieldAccessor(obj).setInt(obj, i);
+ }
+
+@@ -843,9 +934,15 @@
+ * by this method fails.
+ * @see Field#set
+ */
++ @CallerSensitive
+ public void setLong(Object obj, long l)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ getFieldAccessor(obj).setLong(obj, l);
+ }
+
+@@ -872,9 +969,15 @@
+ * by this method fails.
+ * @see Field#set
+ */
++ @CallerSensitive
+ public void setFloat(Object obj, float f)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ getFieldAccessor(obj).setFloat(obj, f);
+ }
+
+@@ -901,20 +1004,25 @@
+ * by this method fails.
+ * @see Field#set
+ */
++ @CallerSensitive
+ public void setDouble(Object obj, double d)
+ throws IllegalArgumentException, IllegalAccessException
+ {
++ if (!override) {
++ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
++ checkAccess(Reflection.getCallerClass(), clazz, obj, modifiers);
++ }
++ }
+ getFieldAccessor(obj).setDouble(obj, d);
+ }
+
+- // Convenience routine which performs security checks
++ // security check is done before calling this method
+ private FieldAccessor getFieldAccessor(Object obj)
+ throws IllegalAccessException
+ {
+- doSecurityCheck(obj);
+ boolean ov = override;
+- FieldAccessor a = (ov)? overrideFieldAccessor : fieldAccessor;
+- return (a != null)? a : acquireFieldAccessor(ov);
++ FieldAccessor a = (ov) ? overrideFieldAccessor : fieldAccessor;
++ return (a != null) ? a : acquireFieldAccessor(ov);
+ }
+
+ // NOTE that there is no synchronization used here. It is correct
+@@ -961,10 +1069,7 @@
+ // NOTE: be very careful if you change the stack depth of this
+ // routine. The depth of the "getCallerClass" call is hardwired so
+ // that the compiler can have an easier time if this gets inlined.
+- private void doSecurityCheck(Object obj) throws IllegalAccessException {
+- if (!override) {
+- if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
+- Class caller = Reflection.getCallerClass(4);
++ private void checkAccess(Class caller, Class clazz, Object obj, int modifiers) throws IllegalAccessException {
+ Class targetClass = ((obj == null || !Modifier.isProtected(modifiers))
+ ? clazz
+ : obj.getClass());
+@@ -980,8 +1085,6 @@
+ securityCheckCache = caller;
+ securityCheckTargetClassCache = targetClass;
+ }
+- }
+- }
+ }
+
+ /*
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/reflect/Method.java
+--- jdk/src/share/classes/java/lang/reflect/Method.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/reflect/Method.java Mon Oct 21 18:05:56 2013 +0100
+@@ -25,6 +25,7 @@
+
+ package java.lang.reflect;
+
++import sun.reflect.CallerSensitive;
+ import sun.reflect.MethodAccessor;
+ import sun.reflect.Reflection;
+ import sun.reflect.generics.repository.MethodRepository;
+@@ -587,13 +588,18 @@
+ * @exception ExceptionInInitializerError if the initialization
+ * provoked by this method fails.
+ */
++ @CallerSensitive
+ public Object invoke(Object obj, Object... args)
+ throws IllegalAccessException, IllegalArgumentException,
+ InvocationTargetException
+ {
+ if (!override) {
+ if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
+- Class caller = Reflection.getCallerClass(1);
++ // Until there is hotspot @CallerSensitive support
++ // can't call Reflection.getCallerClass() here
++ // Workaround for now: add a frame getCallerClass to
++ // make the caller at stack depth 2
++ Class<?> caller = getCallerClass();
+ Class targetClass = ((obj == null || !Modifier.isProtected(modifiers))
+ ? clazz
+ : obj.getClass());
+@@ -616,6 +622,16 @@
+ return methodAccessor.invoke(obj, args);
+ }
+
++ /*
++ * This method makes the frame count to be 2 to find the caller
++ */
++ @CallerSensitive
++ private Class<?> getCallerClass() {
++ // Reflection.getCallerClass() currently returns the frame at depth 2
++ // before the hotspot support is in.
++ return Reflection.getCallerClass();
++ }
++
+ /**
+ * Returns {@code true} if this method is a bridge
+ * method; returns {@code false} otherwise.
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/lang/reflect/Proxy.java
+--- jdk/src/share/classes/java/lang/reflect/Proxy.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/lang/reflect/Proxy.java Mon Oct 21 18:05:56 2013 +0100
+@@ -38,6 +38,7 @@
+ import java.util.Set;
+ import java.util.WeakHashMap;
+ import sun.misc.ProxyGenerator;
++import sun.reflect.CallerSensitive;
+ import sun.reflect.Reflection;
+ import sun.reflect.misc.ReflectUtil;
+ import sun.security.util.SecurityConstants;
+@@ -404,28 +405,21 @@
+ * @throws NullPointerException if the {@code interfaces} array
+ * argument or any of its elements are {@code null}
+ */
++ @CallerSensitive
+ public static Class<?> getProxyClass(ClassLoader loader,
+ Class<?>... interfaces)
+ throws IllegalArgumentException
+ {
+- return getProxyClass0(loader, interfaces); // stack walk magic: do not refactor
+- }
+-
+- private static void checkProxyLoader(ClassLoader ccl,
+- ClassLoader loader)
+- {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+- if (loader == null && ccl != null) {
+- if (!ProxyAccessHelper.allowNullLoader) {
+- sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+- }
+- }
++ checkProxyAccess(Reflection.getCallerClass(), loader, interfaces);
+ }
++
++ return getProxyClass0(loader, interfaces);
+ }
+
+ /*
+- * Generate a proxy class (caller-sensitive).
++ * Check permissions required to create a proxy class.
+ *
+ * To define a proxy class, it performs the access checks as in
+ * Class.forName (VM will invoke ClassLoader.checkPackageAccess):
+@@ -442,16 +436,28 @@
+ * will throw IllegalAccessError when the generated proxy class is
+ * being defined via the defineClass0 method.
+ */
++ private static void checkProxyAccess(Class<?> caller,
++ ClassLoader loader,
++ Class<?>... interfaces)
++ {
++ SecurityManager sm = System.getSecurityManager();
++ if (sm != null) {
++ ClassLoader ccl = caller.getClassLoader();
++ if (loader == null && ccl != null) {
++ if (!ProxyAccessHelper.allowNullLoader) {
++ sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
++ }
++ }
++ ReflectUtil.checkProxyPackageAccess(ccl, interfaces);
++ }
++ }
++
++ /**
++ * Generate a proxy class. Must call the checkProxyAccess method
++ * to perform permission checks before calling this.
++ */
+ private static Class<?> getProxyClass0(ClassLoader loader,
+ Class<?>... interfaces) {
+- SecurityManager sm = System.getSecurityManager();
+- if (sm != null) {
+- final int CALLER_FRAME = 3; // 0: Reflection, 1: getProxyClass0 2: Proxy 3: caller
+- final Class<?> caller = Reflection.getCallerClass(CALLER_FRAME);
+- final ClassLoader ccl = caller.getClassLoader();
+- checkProxyLoader(ccl, loader);
+- ReflectUtil.checkProxyPackageAccess(ccl, interfaces);
+- }
+ if (interfaces.length > 65535) {
+ throw new IllegalArgumentException("interface limit exceeded");
+ }
+@@ -692,6 +698,7 @@
+ * if the invocation handler, {@code h}, is
+ * {@code null}
+ */
++ @CallerSensitive
+ public static Object newProxyInstance(ClassLoader loader,
+ Class<?>[] interfaces,
+ InvocationHandler h)
+@@ -701,10 +708,15 @@
+ throw new NullPointerException();
+ }
+
++ final SecurityManager sm = System.getSecurityManager();
++ if (sm != null) {
++ checkProxyAccess(Reflection.getCallerClass(), loader, interfaces);
++ }
++
+ /*
+ * Look up or generate the designated proxy class.
+ */
+- Class<?> cl = getProxyClass0(loader, interfaces); // stack walk magic: do not refactor
++ Class<?> cl = getProxyClass0(loader, interfaces);
+
+ /*
+ * Invoke its constructor with the designated invocation handler.
+@@ -712,7 +724,6 @@
+ try {
+ final Constructor<?> cons = cl.getConstructor(constructorParams);
+ final InvocationHandler ih = h;
+- SecurityManager sm = System.getSecurityManager();
+ if (sm != null && ProxyAccessHelper.needsNewInstanceCheck(cl)) {
+ // create proxy instance with doPrivilege as the proxy class may
+ // implement non-public interfaces that requires a special permission
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/security/AccessController.java
+--- jdk/src/share/classes/java/security/AccessController.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/security/AccessController.java Mon Oct 21 18:05:56 2013 +0100
+@@ -26,6 +26,8 @@
+ package java.security;
+
+ import sun.security.util.Debug;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+
+ /**
+ * <p> The AccessController class is used for access control operations
+@@ -264,6 +266,7 @@
+ * @see java.security.DomainCombiner
+ */
+
++ @CallerSensitive
+ public static native <T> T doPrivileged(PrivilegedAction<T> action);
+
+ /**
+@@ -288,14 +291,14 @@
+ *
+ * @since 1.6
+ */
++ @CallerSensitive
+ public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) {
+-
+ AccessControlContext acc = getStackAccessControlContext();
+ if (acc == null) {
+ return AccessController.doPrivileged(action);
+ }
+ DomainCombiner dc = acc.getAssignedCombiner();
+- return AccessController.doPrivileged(action, preserveCombiner(dc));
++ return AccessController.doPrivileged(action, preserveCombiner(dc, Reflection.getCallerClass()));
+ }
+
+
+@@ -326,6 +329,7 @@
+ * @see #doPrivileged(PrivilegedAction)
+ * @see #doPrivileged(PrivilegedExceptionAction,AccessControlContext)
+ */
++ @CallerSensitive
+ public static native <T> T doPrivileged(PrivilegedAction<T> action,
+ AccessControlContext context);
+
+@@ -353,6 +357,7 @@
+ * @see #doPrivilegedWithCombiner(PrivilegedExceptionAction)
+ * @see java.security.DomainCombiner
+ */
++ @CallerSensitive
+ public static native <T> T
+ doPrivileged(PrivilegedExceptionAction<T> action)
+ throws PrivilegedActionException;
+@@ -383,6 +388,7 @@
+ *
+ * @since 1.6
+ */
++ @CallerSensitive
+ public static <T> T doPrivilegedWithCombiner
+ (PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
+
+@@ -391,26 +397,18 @@
+ return AccessController.doPrivileged(action);
+ }
+ DomainCombiner dc = acc.getAssignedCombiner();
+- return AccessController.doPrivileged(action, preserveCombiner(dc));
++ return AccessController.doPrivileged(action, preserveCombiner(dc, Reflection.getCallerClass()));
+ }
+
+ /**
+ * preserve the combiner across the doPrivileged call
+ */
+- private static AccessControlContext preserveCombiner
+- (DomainCombiner combiner) {
+-
+- /**
+- * callerClass[0] = Reflection.getCallerClass
+- * callerClass[1] = AccessController.preserveCombiner
+- * callerClass[2] = AccessController.doPrivileged
+- * callerClass[3] = caller
+- */
+- final Class callerClass = sun.reflect.Reflection.getCallerClass(3);
++ private static AccessControlContext preserveCombiner(DomainCombiner combiner,
++ final Class<?> caller) {
+ ProtectionDomain callerPd = doPrivileged
+ (new PrivilegedAction<ProtectionDomain>() {
+ public ProtectionDomain run() {
+- return callerClass.getProtectionDomain();
++ return caller.getProtectionDomain();
+ }
+ });
+
+@@ -455,6 +453,7 @@
+ * @see #doPrivileged(PrivilegedAction)
+ * @see #doPrivileged(PrivilegedExceptionAction,AccessControlContext)
+ */
++ @CallerSensitive
+ public static native <T> T
+ doPrivileged(PrivilegedExceptionAction<T> action,
+ AccessControlContext context)
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/sql/DriverManager.java
+--- jdk/src/share/classes/java/sql/DriverManager.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/sql/DriverManager.java Mon Oct 21 18:05:56 2013 +0100
+@@ -30,6 +30,8 @@
+ import java.util.ServiceLoader;
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+
+
+ /**
+@@ -159,14 +161,10 @@
+ * @return a Connection to the URL
+ * @exception SQLException if a database access error occurs
+ */
++ @CallerSensitive
+ public static Connection getConnection(String url,
+ java.util.Properties info) throws SQLException {
+-
+- // Gets the classloader of the code that called this method, may
+- // be null.
+- ClassLoader callerCL = DriverManager.getCallerClassLoader();
+-
+- return (getConnection(url, info, callerCL));
++ return (getConnection(url, info, Reflection.getCallerClass()));
+ }
+
+ /**
+@@ -182,14 +180,11 @@
+ * @return a connection to the URL
+ * @exception SQLException if a database access error occurs
+ */
++ @CallerSensitive
+ public static Connection getConnection(String url,
+ String user, String password) throws SQLException {
+ java.util.Properties info = new java.util.Properties();
+
+- // Gets the classloader of the code that called this method, may
+- // be null.
+- ClassLoader callerCL = DriverManager.getCallerClassLoader();
+-
+ if (user != null) {
+ info.put("user", user);
+ }
+@@ -197,7 +192,7 @@
+ info.put("password", password);
+ }
+
+- return (getConnection(url, info, callerCL));
++ return (getConnection(url, info, Reflection.getCallerClass()));
+ }
+
+ /**
+@@ -210,16 +205,12 @@
+ * @return a connection to the URL
+ * @exception SQLException if a database access error occurs
+ */
++ @CallerSensitive
+ public static Connection getConnection(String url)
+ throws SQLException {
+
+ java.util.Properties info = new java.util.Properties();
+-
+- // Gets the classloader of the code that called this method, may
+- // be null.
+- ClassLoader callerCL = DriverManager.getCallerClassLoader();
+-
+- return (getConnection(url, info, callerCL));
++ return (getConnection(url, info, Reflection.getCallerClass()));
+ }
+
+ /**
+@@ -233,6 +224,7 @@
+ * that can connect to the given URL
+ * @exception SQLException if a database access error occurs
+ */
++ @CallerSensitive
+ public static Driver getDriver(String url)
+ throws SQLException {
+ java.util.Vector drivers = null;
+@@ -248,9 +240,7 @@
+ drivers = readDrivers;
+ }
+
+- // Gets the classloader of the code that called this method, may
+- // be null.
+- ClassLoader callerCL = DriverManager.getCallerClassLoader();
++ Class<?> callerClass = Reflection.getCallerClass();
+
+ // Walk through the loaded drivers attempting to locate someone
+ // who understands the given URL.
+@@ -258,7 +248,7 @@
+ DriverInfo di = (DriverInfo)drivers.elementAt(i);
+ // If the caller does not have permission to load the driver then
+ // skip it.
+- if ( getCallerClass(callerCL, di.driverClassName ) !=
++ if ( getCallerClass(callerClass, di.driverClassName ) !=
+ di.driverClass ) {
+ println(" skipping: " + di);
+ continue;
+@@ -319,11 +309,10 @@
+ * @param driver the JDBC Driver to drop
+ * @exception SQLException if a database access error occurs
+ */
++ @CallerSensitive
+ public static synchronized void deregisterDriver(Driver driver)
+ throws SQLException {
+- // Gets the classloader of the code that called this method,
+- // may be null.
+- ClassLoader callerCL = DriverManager.getCallerClassLoader();
++ Class<?> callerClass = Reflection.getCallerClass();
+ println("DriverManager.deregisterDriver: " + driver);
+
+ // Walk through the loaded drivers.
+@@ -343,7 +332,7 @@
+
+ // If the caller does not have permission to load the driver then
+ // throw a security exception.
+- if (getCallerClass(callerCL, di.driverClassName ) != di.driverClass ) {
++ if (getCallerClass(callerClass, di.driverClassName ) != di.driverClass) {
+ throw new SecurityException();
+ }
+
+@@ -363,6 +352,7 @@
+ *
+ * @return the list of JDBC Drivers loaded by the caller's class loader
+ */
++ @CallerSensitive
+ public static java.util.Enumeration<Driver> getDrivers() {
+ java.util.Vector<Driver> result = new java.util.Vector<Driver>();
+ java.util.Vector drivers = null;
+@@ -376,16 +366,14 @@
+ drivers = readDrivers;
+ }
+
+- // Gets the classloader of the code that called this method, may
+- // be null.
+- ClassLoader callerCL = DriverManager.getCallerClassLoader();
++ Class<?> callerClass = Reflection.getCallerClass();
+
+ // Walk through the loaded drivers.
+ for (int i = 0; i < drivers.size(); i++) {
+ DriverInfo di = (DriverInfo)drivers.elementAt(i);
+ // If the caller does not have permission to load the driver then
+ // skip it.
+- if ( getCallerClass(callerCL, di.driverClassName ) != di.driverClass ) {
++ if ( getCallerClass(callerClass, di.driverClassName) != di.driverClass ) {
+ println(" skipping: " + di);
+ continue;
+ }
+@@ -481,6 +469,12 @@
+
+ //------------------------------------------------------------------------
+
++ private static Class getCallerClass(Class<?> caller,
++ String driverClassName) {
++ ClassLoader callerCL = caller != null ? caller.getClassLoader() : null;
++ return getCallerClass(callerCL, driverClassName);
++ }
++
+ // Returns the class object that would be created if the code calling the
+ // driver manager had loaded the driver class, or null if the class
+ // is inaccessible.
+@@ -573,7 +567,7 @@
+
+ // Worker method called by the public getConnection() methods.
+ private static Connection getConnection(
+- String url, java.util.Properties info, ClassLoader callerCL) throws SQLException {
++ String url, java.util.Properties info, Class<?> caller) throws SQLException {
+ java.util.Vector drivers = null;
+ /*
+ * When callerCl is null, we should check the application's
+@@ -581,11 +575,12 @@
+ * classloader, so that the JDBC driver class outside rt.jar
+ * can be loaded from here.
+ */
+- synchronized(DriverManager.class) {
+- // synchronize loading of the correct classloader.
+- if(callerCL == null) {
+- callerCL = Thread.currentThread().getContextClassLoader();
+- }
++ ClassLoader callerCL = caller != null ? caller.getClassLoader() : null;
++ synchronized (DriverManager.class) {
++ // synchronize loading of the correct classloader.
++ if (callerCL == null) {
++ callerCL = Thread.currentThread().getContextClassLoader();
++ }
+ }
+
+ if(url == null) {
+@@ -666,10 +661,6 @@
+ private static boolean initialized = false;
+
+ private static Object logSync = new Object();
+-
+- /* Returns the caller's class loader, or null if none */
+- private static native ClassLoader getCallerClassLoader();
+-
+ }
+
+ // DriverInfo is a package-private support class.
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/util/ResourceBundle.java
+--- jdk/src/share/classes/java/util/ResourceBundle.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/util/ResourceBundle.java Mon Oct 21 18:05:56 2013 +0100
+@@ -56,6 +56,8 @@
+ import java.util.concurrent.ConcurrentMap;
+ import java.util.jar.JarEntry;
+
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+
+ /**
+ *
+@@ -421,14 +423,10 @@
+
+ /*
+ * Automatic determination of the ClassLoader to be used to load
+- * resources on behalf of the client. N.B. The client is getLoader's
+- * caller's caller.
++ * resources on behalf of the client.
+ */
+- private static ClassLoader getLoader() {
+- Class[] stack = getClassContext();
+- /* Magic number 2 identifies our caller's caller */
+- Class c = stack[2];
+- ClassLoader cl = (c == null) ? null : c.getClassLoader();
++ private static ClassLoader getLoader(Class<?> caller) {
++ ClassLoader cl = caller == null ? null : caller.getClassLoader();
+ if (cl == null) {
+ // When the caller's loader is the boot class loader, cl is null
+ // here. In that case, ClassLoader.getSystemClassLoader() may
+@@ -442,8 +440,6 @@
+ return cl;
+ }
+
+- private static native Class[] getClassContext();
+-
+ /**
+ * A wrapper of ClassLoader.getSystemClassLoader().
+ */
+@@ -728,11 +724,12 @@
+ * if no resource bundle for the specified base name can be found
+ * @return a resource bundle for the given base name and the default locale
+ */
++ @CallerSensitive
+ public static final ResourceBundle getBundle(String baseName)
+ {
+ return getBundleImpl(baseName, Locale.getDefault(),
+ /* must determine loader here, else we break stack invariant */
+- getLoader(),
++ getLoader(Reflection.getCallerClass()),
+ Control.INSTANCE);
+ }
+
+@@ -770,11 +767,12 @@
+ * needed.
+ * @since 1.6
+ */
++ @CallerSensitive
+ public static final ResourceBundle getBundle(String baseName,
+ Control control) {
+ return getBundleImpl(baseName, Locale.getDefault(),
+ /* must determine loader here, else we break stack invariant */
+- getLoader(),
++ getLoader(Reflection.getCallerClass()),
+ control);
+ }
+
+@@ -799,12 +797,13 @@
+ * if no resource bundle for the specified base name can be found
+ * @return a resource bundle for the given base name and locale
+ */
++ @CallerSensitive
+ public static final ResourceBundle getBundle(String baseName,
+ Locale locale)
+ {
+ return getBundleImpl(baseName, locale,
+ /* must determine loader here, else we break stack invariant */
+- getLoader(),
++ getLoader(Reflection.getCallerClass()),
+ Control.INSTANCE);
+ }
+
+@@ -845,11 +844,12 @@
+ * needed.
+ * @since 1.6
+ */
++ @CallerSensitive
+ public static final ResourceBundle getBundle(String baseName, Locale targetLocale,
+ Control control) {
+ return getBundleImpl(baseName, targetLocale,
+ /* must determine loader here, else we break stack invariant */
+- getLoader(),
++ getLoader(Reflection.getCallerClass()),
+ control);
+ }
+
+@@ -1716,8 +1716,9 @@
+ * @since 1.6
+ * @see ResourceBundle.Control#getTimeToLive(String,Locale)
+ */
++ @CallerSensitive
+ public static final void clearCache() {
+- clearCache(getLoader());
++ clearCache(getLoader(Reflection.getCallerClass()));
+ }
+
+ /**
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
+--- jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java Mon Oct 21 18:05:56 2013 +0100
+@@ -34,8 +34,10 @@
+ */
+
+ package java.util.concurrent.atomic;
++import java.lang.reflect.*;
+ import sun.misc.Unsafe;
+-import java.lang.reflect.*;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+
+ /**
+ * A reflection-based utility that enables atomic updates to
+@@ -69,8 +71,9 @@
+ * @throws RuntimeException with a nested reflection-based
+ * exception if the class does not hold field or is the wrong type
+ */
++ @CallerSensitive
+ public static <U> AtomicIntegerFieldUpdater<U> newUpdater(Class<U> tclass, String fieldName) {
+- return new AtomicIntegerFieldUpdaterImpl<U>(tclass, fieldName);
++ return new AtomicIntegerFieldUpdaterImpl<U>(tclass, fieldName, Reflection.getCallerClass());
+ }
+
+ /**
+@@ -268,13 +271,11 @@
+ private final Class<T> tclass;
+ private final Class cclass;
+
+- AtomicIntegerFieldUpdaterImpl(Class<T> tclass, String fieldName) {
++ AtomicIntegerFieldUpdaterImpl(Class<T> tclass, String fieldName, Class<?> caller) {
+ Field field = null;
+- Class caller = null;
+ int modifiers = 0;
+ try {
+ field = tclass.getDeclaredField(fieldName);
+- caller = sun.reflect.Reflection.getCallerClass(3);
+ modifiers = field.getModifiers();
+ sun.reflect.misc.ReflectUtil.ensureMemberAccess(
+ caller, tclass, null, modifiers);
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
+--- jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java Mon Oct 21 18:05:56 2013 +0100
+@@ -34,8 +34,10 @@
+ */
+
+ package java.util.concurrent.atomic;
++import java.lang.reflect.*;
+ import sun.misc.Unsafe;
+-import java.lang.reflect.*;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+
+ /**
+ * A reflection-based utility that enables atomic updates to
+@@ -69,11 +71,13 @@
+ * @throws RuntimeException with a nested reflection-based
+ * exception if the class does not hold field or is the wrong type.
+ */
++ @CallerSensitive
+ public static <U> AtomicLongFieldUpdater<U> newUpdater(Class<U> tclass, String fieldName) {
++ Class<?> caller = Reflection.getCallerClass();
+ if (AtomicLong.VM_SUPPORTS_LONG_CAS)
+- return new CASUpdater<U>(tclass, fieldName);
++ return new CASUpdater<U>(tclass, fieldName, caller);
+ else
+- return new LockedUpdater<U>(tclass, fieldName);
++ return new LockedUpdater<U>(tclass, fieldName, caller);
+ }
+
+ /**
+@@ -267,13 +271,11 @@
+ private final Class<T> tclass;
+ private final Class cclass;
+
+- CASUpdater(Class<T> tclass, String fieldName) {
++ CASUpdater(Class<T> tclass, String fieldName, Class<?> caller) {
+ Field field = null;
+- Class caller = null;
+ int modifiers = 0;
+ try {
+ field = tclass.getDeclaredField(fieldName);
+- caller = sun.reflect.Reflection.getCallerClass(3);
+ modifiers = field.getModifiers();
+ sun.reflect.misc.ReflectUtil.ensureMemberAccess(
+ caller, tclass, null, modifiers);
+@@ -350,13 +352,11 @@
+ private final Class<T> tclass;
+ private final Class cclass;
+
+- LockedUpdater(Class<T> tclass, String fieldName) {
++ LockedUpdater(Class<T> tclass, String fieldName, Class<?> caller) {
+ Field field = null;
+- Class caller = null;
+ int modifiers = 0;
+ try {
+ field = tclass.getDeclaredField(fieldName);
+- caller = sun.reflect.Reflection.getCallerClass(3);
+ modifiers = field.getModifiers();
+ sun.reflect.misc.ReflectUtil.ensureMemberAccess(
+ caller, tclass, null, modifiers);
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
+--- jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java Mon Oct 21 18:05:56 2013 +0100
+@@ -34,8 +34,10 @@
+ */
+
+ package java.util.concurrent.atomic;
++import java.lang.reflect.*;
+ import sun.misc.Unsafe;
+-import java.lang.reflect.*;
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
+
+ /**
+ * A reflection-based utility that enables atomic updates to
+@@ -89,10 +91,12 @@
+ * @throws RuntimeException with a nested reflection-based
+ * exception if the class does not hold field or is the wrong type.
+ */
++ @CallerSensitive
+ public static <U, W> AtomicReferenceFieldUpdater<U,W> newUpdater(Class<U> tclass, Class<W> vclass, String fieldName) {
+ return new AtomicReferenceFieldUpdaterImpl<U,W>(tclass,
+ vclass,
+- fieldName);
++ fieldName,
++ Reflection.getCallerClass());
+ }
+
+ /**
+@@ -200,14 +204,13 @@
+
+ AtomicReferenceFieldUpdaterImpl(Class<T> tclass,
+ Class<V> vclass,
+- String fieldName) {
++ String fieldName,
++ Class<?> caller) {
+ Field field = null;
+ Class fieldClass = null;
+- Class caller = null;
+ int modifiers = 0;
+ try {
+ field = tclass.getDeclaredField(fieldName);
+- caller = sun.reflect.Reflection.getCallerClass(3);
+ modifiers = field.getModifiers();
+ sun.reflect.misc.ReflectUtil.ensureMemberAccess(
+ caller, tclass, null, modifiers);
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/java/util/logging/Logger.java
+--- jdk/src/share/classes/java/util/logging/Logger.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/java/util/logging/Logger.java Mon Oct 21 18:05:56 2013 +0100
+@@ -298,13 +298,10 @@
+ }
+ }
+
+- private static Logger demandLogger(String name, String resourceBundleName) {
++ private static Logger demandLogger(String name, String resourceBundleName, Class<?> caller) {
+ LogManager manager = LogManager.getLogManager();
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null && !SystemLoggerHelper.disableCallerCheck) {
+- // 0: Reflection 1: Logger.getLoggerContext 2: Logger.getLogger 3: caller
+- final int SKIP_FRAMES = 3;
+- Class<?> caller = sun.reflect.Reflection.getCallerClass(SKIP_FRAMES);
+ if (caller.getClassLoader() == null) {
+ return manager.demandSystemLogger(name, resourceBundleName);
+ }
+@@ -339,8 +336,9 @@
+ * @return a suitable Logger
+ * @throws NullPointerException if the name is null.
+ */
++ @CallerSensitive
+ public static synchronized Logger getLogger(String name) {
+- return demandLogger(name, null);
++ return demandLogger(name, null, Reflection.getCallerClass());
+ }
+
+ /**
+@@ -382,8 +380,9 @@
+ * a different resource bundle name.
+ * @throws NullPointerException if the name is null.
+ */
++ @CallerSensitive
+ public static synchronized Logger getLogger(String name, String resourceBundleName) {
+- Logger result = demandLogger(name, resourceBundleName);
++ Logger result = demandLogger(name, resourceBundleName, Reflection.getCallerClass());
+ if (result.resourceBundleName == null) {
+ // Note: we may get a MissingResourceException here.
+ result.setupResourceInfo(resourceBundleName);
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java
+--- jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java Mon Oct 21 18:05:56 2013 +0100
+@@ -30,6 +30,8 @@
+ import java.util.Map;
+ import java.lang.reflect.*;
+ import javax.sql.rowset.RowSetWarning;
++import sun.reflect.CallerSensitive;
++import sun.reflect.misc.ReflectUtil;
+
+ /**
+ * A serializable mapping in the Java programming language of an SQL
+@@ -137,6 +139,7 @@
+ * @throws SerialException if an error is encountered accessing
+ * the serialized object
+ */
++ @CallerSensitive
+ public Field[] getFields() throws SerialException {
+ if (fields != null) {
+ Class c = this.obj.getClass();
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/sun/misc/Unsafe.java
+--- jdk/src/share/classes/sun/misc/Unsafe.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/sun/misc/Unsafe.java Mon Oct 21 18:05:56 2013 +0100
+@@ -28,6 +28,9 @@
+ import java.security.*;
+ import java.lang.reflect.*;
+
++import sun.reflect.CallerSensitive;
++import sun.reflect.Reflection;
++
+
+ /**
+ * A collection of methods for performing low-level, unsafe operations.
+@@ -80,8 +83,9 @@
+ * <code>checkPropertiesAccess</code> method doesn't allow
+ * access to the system properties.
+ */
++ @CallerSensitive
+ public static Unsafe getUnsafe() {
+- Class cc = sun.reflect.Reflection.getCallerClass(2);
++ Class cc = Reflection.getCallerClass();
+ if (cc.getClassLoader() != null)
+ throw new SecurityException("Unsafe");
+ return theUnsafe;
+@@ -708,6 +712,12 @@
+ ClassLoader loader,
+ ProtectionDomain protectionDomain);
+
++ /**
++ * @deprecated Use defineClass(String, byte[], int, int, ClassLoader, ProtectionDomain)
++ * instead. This method will be removed in JDK 8.
++ */
++ @Deprecated
++ @CallerSensitive
+ public native Class defineClass(String name, byte[] b, int off, int len);
+
+ /** Allocate an instance but do not run any constructor.
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/sun/reflect/CallerSensitive.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/src/share/classes/sun/reflect/CallerSensitive.java Mon Oct 21 18:05:56 2013 +0100
+@@ -0,0 +1,41 @@
++/*
++ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation. Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package sun.reflect;
++
++import java.lang.annotation.*;
++import static java.lang.annotation.ElementType.*;
++
++/**
++ * A method annotated @CallerSensitive is sensitive to its calling class,
++ * via {@link sun.reflect.Reflection#getCallerClass Reflection.getCallerClass},
++ * or via some equivalent.
++ *
++ * @author John R. Rose
++ */
++@Retention(RetentionPolicy.RUNTIME)
++@Target({METHOD})
++public @interface CallerSensitive {
++}
+diff -r e56220b54fe2 -r d206cb658a99 src/share/classes/sun/reflect/Reflection.java
+--- jdk/src/share/classes/sun/reflect/Reflection.java Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/classes/sun/reflect/Reflection.java Mon Oct 21 18:05:56 2013 +0100
+@@ -52,16 +52,11 @@
+ methodFilterMap = new HashMap<Class,String[]>();
+ }
+
+- /** Returns the class of the method <code>realFramesToSkip</code>
+- frames up the stack (zero-based), ignoring frames associated
+- with java.lang.reflect.Method.invoke() and its implementation.
+- The first frame is that associated with this method, so
+- <code>getCallerClass(0)</code> returns the Class object for
+- sun.reflect.Reflection. Frames associated with
+- java.lang.reflect.Method.invoke() and its implementation are
+- completely ignored and do not count toward the number of "real"
+- frames skipped. */
+- public static native Class getCallerClass(int realFramesToSkip);
++ /** Returns the class of the caller of the method calling this method,
++ ignoring frames associated with java.lang.reflect.Method.invoke()
++ and its implementation. */
++ @CallerSensitive
++ public static native Class getCallerClass();
+
+ /** Retrieves the access flags written to the class file. For
+ inner classes these flags may differ from those returned by
+@@ -322,4 +317,27 @@
+ }
+ return newMembers;
+ }
++
++ /**
++ * Tests if the given method is caller-sensitive and the declaring class
++ * is defined by either the bootstrap class loader or extension class loader.
++ */
++ public static boolean isCallerSensitive(Method m) {
++ final ClassLoader loader = m.getDeclaringClass().getClassLoader();
++ if (loader == null || isExtClassLoader(loader)) {
++ return m.isAnnotationPresent(CallerSensitive.class);
++ }
++ return false;
++ }
++
++ private static boolean isExtClassLoader(ClassLoader loader) {
++ ClassLoader cl = ClassLoader.getSystemClassLoader();
++ while (cl != null) {
++ if (cl.getParent() == null && cl == loader) {
++ return true;
++ }
++ cl = cl.getParent();
++ }
++ return false;
++ }
+ }
+diff -r e56220b54fe2 -r d206cb658a99 src/share/native/java/lang/SecurityManager.c
+--- jdk/src/share/native/java/lang/SecurityManager.c Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/native/java/lang/SecurityManager.c Mon Oct 21 18:05:56 2013 +0100
+@@ -29,7 +29,6 @@
+
+ #include "java_lang_SecurityManager.h"
+ #include "java_lang_ClassLoader.h"
+-#include "java_util_ResourceBundle.h"
+
+ /*
+ * Make sure a security manager instance is initialized.
+diff -r e56220b54fe2 -r d206cb658a99 src/share/native/sun/reflect/Reflection.c
+--- jdk/src/share/native/sun/reflect/Reflection.c Wed Oct 16 05:39:53 2013 +0100
++++ jdk/src/share/native/sun/reflect/Reflection.c Mon Oct 21 18:05:56 2013 +0100
+@@ -27,9 +27,11 @@
+ #include "sun_reflect_Reflection.h"
+
+ JNIEXPORT jclass JNICALL Java_sun_reflect_Reflection_getCallerClass
+-(JNIEnv *env, jclass unused, jint depth)
++(JNIEnv *env, jclass unused)
+ {
+- return JVM_GetCallerClass(env, depth);
++ // Until there is hotspot @CallerSensitive support,
++ // depth must always be 2 to get the immediate caller
++ return JVM_GetCallerClass(env, 2);
+ }
+
+ JNIEXPORT jint JNICALL Java_sun_reflect_Reflection_getClassAccessFlags
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java Mon Oct 21 18:05:56 2013 +0100
+@@ -0,0 +1,248 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++import com.sun.tools.classfile.*;
++import static com.sun.tools.classfile.ConstantPool.*;
++import java.io.File;
++import java.io.IOException;
++import java.lang.reflect.InvocationTargetException;
++import java.nio.file.FileVisitResult;
++import java.nio.file.Files;
++import java.nio.file.Path;
++import java.nio.file.Paths;
++import java.nio.file.SimpleFileVisitor;
++import java.nio.file.attribute.BasicFileAttributes;
++import java.util.ArrayList;
++import java.util.List;
++import java.util.Set;
++import java.util.concurrent.Callable;
++import java.util.concurrent.ExecutionException;
++import java.util.concurrent.ExecutorService;
++import java.util.concurrent.Executors;
++import java.util.concurrent.FutureTask;
++
++/*
++ * @test
++ * @bug 8010117
++ * @summary Verify if CallerSensitive methods are annotated with
++ * sun.reflect.CallerSensitive annotation
++ * @build CallerSensitiveFinder MethodFinder ClassFileReader
++ * @run main/othervm/timeout=900 -mx800m CallerSensitiveFinder
++ */
++public class CallerSensitiveFinder extends MethodFinder {
++ private static int numThreads = 3;
++ private static boolean verbose = false;
++ public static void main(String[] args) throws Exception {
++ List<Path> classes = new ArrayList<>();
++ String testclasses = System.getProperty("test.classes", ".");
++ int i = 0;
++ while (i < args.length) {
++ String arg = args[i++];
++ if (arg.equals("-v")) {
++ verbose = true;
++ } else {
++ Path p = Paths.get(testclasses, arg);
++ if (!p.toFile().exists()) {
++ throw new IllegalArgumentException(arg + " does not exist");
++ }
++ classes.add(p);
++ }
++ }
++ if (classes.isEmpty()) {
++ classes.addAll(PlatformClassPath.getJREClasses());
++ }
++ final String method = "sun/reflect/Reflection.getCallerClass";
++ CallerSensitiveFinder csfinder = new CallerSensitiveFinder(method);
++
++ List<String> errors = csfinder.run(classes);
++ if (!errors.isEmpty()) {
++ throw new RuntimeException(errors.size() +
++ " caller-sensitive methods are missing @CallerSensitive annotation");
++ }
++ }
++
++ private final List<String> csMethodsMissingAnnotation = new ArrayList<>();
++ private final java.lang.reflect.Method mhnCallerSensitiveMethod;
++ public CallerSensitiveFinder(String... methods) throws Exception {
++ super(methods);
++ this.mhnCallerSensitiveMethod = getIsCallerSensitiveMethod();
++ }
++
++ static java.lang.reflect.Method getIsCallerSensitiveMethod()
++ throws ClassNotFoundException, NoSuchMethodException
++ {
++ Class<?> cls = Class.forName("java.lang.invoke.MethodHandleNatives");
++ java.lang.reflect.Method m = cls.getDeclaredMethod("isCallerSensitiveMethod", Class.class, String.class);
++ m.setAccessible(true);
++ return m;
++ }
++
++ boolean inMethodHandlesList(String classname, String method) {
++ Class<?> cls;
++ try {
++ cls = Class.forName(classname.replace('/', '.'),
++ false,
++ ClassLoader.getSystemClassLoader());
++ return (Boolean) mhnCallerSensitiveMethod.invoke(null, cls, method);
++ } catch (ClassNotFoundException|IllegalAccessException e) {
++ throw new RuntimeException(e);
++ } catch (InvocationTargetException e) {
++ throw new RuntimeException(e.getCause());
++ }
++ }
++
++ public List<String> run(List<Path> classes) throws IOException, InterruptedException,
++ ExecutionException, ConstantPoolException
++ {
++ ExecutorService pool = Executors.newFixedThreadPool(numThreads);
++ for (Path path : classes) {
++ ClassFileReader reader = ClassFileReader.newInstance(path.toFile());
++ for (ClassFile cf : reader.getClassFiles()) {
++ String classFileName = cf.getName();
++ // for each ClassFile
++ // parse constant pool to find matching method refs
++ // parse each method (caller)
++ // - visit and find method references matching the given method name
++ pool.submit(getTask(cf));
++ }
++ }
++ waitForCompletion();
++ pool.shutdown();
++ return csMethodsMissingAnnotation;
++ }
++
++ private static final String CALLER_SENSITIVE_ANNOTATION = "Lsun/reflect/CallerSensitive;";
++ private static boolean isCallerSensitive(Method m, ConstantPool cp)
++ throws ConstantPoolException
++ {
++ RuntimeAnnotations_attribute attr =
++ (RuntimeAnnotations_attribute)m.attributes.get(Attribute.RuntimeVisibleAnnotations);
++ int index = 0;
++ if (attr != null) {
++ for (int i = 0; i < attr.annotations.length; i++) {
++ Annotation ann = attr.annotations[i];
++ String annType = cp.getUTF8Value(ann.type_index);
++ if (CALLER_SENSITIVE_ANNOTATION.equals(annType)) {
++ return true;
++ }
++ }
++ }
++ return false;
++ }
++
++ public void referenceFound(ClassFile cf, Method m, Set<Integer> refs)
++ throws ConstantPoolException
++ {
++ String name = String.format("%s#%s %s", cf.getName(),
++ m.getName(cf.constant_pool),
++ m.descriptor.getValue(cf.constant_pool));
++ if (!CallerSensitiveFinder.isCallerSensitive(m, cf.constant_pool)) {
++ csMethodsMissingAnnotation.add(name);
++ System.err.println(" Missing @CallerSensitive: " + name);
++ } else if (verbose) {
++ System.out.format("Caller found: %s%n", name);
++ }
++ if (m.access_flags.is(AccessFlags.ACC_PUBLIC)) {
++ if (!inMethodHandlesList(cf.getName(), m.getName(cf.constant_pool))) {
++ csMethodsMissingAnnotation.add(name);
++ System.err.println(" Missing in MethodHandleNatives list: " + name);
++ } else if (verbose) {
++ System.out.format("Caller found in MethodHandleNatives list: %s%n", name);
++
++ }
++ }
++ }
++
++ private final List<FutureTask<String>> tasks = new ArrayList<FutureTask<String>>();
++ private FutureTask<String> getTask(final ClassFile cf) {
++ FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
++ public String call() throws Exception {
++ return parse(cf);
++ }
++ });
++ tasks.add(task);
++ return task;
++ }
++
++ private void waitForCompletion() throws InterruptedException, ExecutionException {
++ for (FutureTask<String> t : tasks) {
++ String s = t.get();
++ }
++ System.out.println("Parsed " + tasks.size() + " classfiles");
++ }
++
++ static class PlatformClassPath {
++ static List<Path> getJREClasses() throws IOException {
++ List<Path> result = new ArrayList<Path>();
++ Path home = Paths.get(System.getProperty("java.home"));
++
++ if (home.endsWith("jre")) {
++ // jar files in <javahome>/jre/lib
++ // skip <javahome>/lib
++ result.addAll(addJarFiles(home.resolve("lib")));
++ } else if (home.resolve("lib").toFile().exists()) {
++ // either a JRE or a jdk build image
++ File classes = home.resolve("classes").toFile();
++ if (classes.exists() && classes.isDirectory()) {
++ // jdk build outputdir
++ result.add(classes.toPath());
++ }
++ // add other JAR files
++ result.addAll(addJarFiles(home.resolve("lib")));
++ } else {
++ throw new RuntimeException("\"" + home + "\" not a JDK home");
++ }
++ return result;
++ }
++
++ static List<Path> addJarFiles(final Path root) throws IOException {
++ final List<Path> result = new ArrayList<Path>();
++ final Path ext = root.resolve("ext");
++ Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
++ @Override
++ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
++ throws IOException {
++ if (dir.equals(root) || dir.equals(ext)) {
++ return FileVisitResult.CONTINUE;
++ } else {
++ // skip other cobundled JAR files
++ return FileVisitResult.SKIP_SUBTREE;
++ }
++ }
++
++ @Override
++ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
++ throws IOException {
++ File f = file.toFile();
++ String fn = f.getName();
++ // parse alt-rt.jar as well
++ if (fn.endsWith(".jar") && !fn.equals("jfxrt.jar")) {
++ result.add(file);
++ }
++ return FileVisitResult.CONTINUE;
++ }
++ });
++ return result;
++ }
++ }
++}
+diff -r e56220b54fe2 -r d206cb658a99 test/sun/reflect/CallerSensitive/ClassFileReader.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/sun/reflect/CallerSensitive/ClassFileReader.java Mon Oct 21 18:05:56 2013 +0100
+@@ -0,0 +1,338 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++import com.sun.tools.classfile.ClassFile;
++import com.sun.tools.classfile.ConstantPoolException;
++import java.io.*;
++import java.nio.file.FileVisitResult;
++import java.nio.file.Files;
++import java.nio.file.Path;
++import java.nio.file.SimpleFileVisitor;
++import java.nio.file.attribute.BasicFileAttributes;
++import java.util.*;
++import java.util.jar.JarEntry;
++import java.util.jar.JarFile;
++
++/**
++ * ClassFileReader reads ClassFile(s) of a given path that can be
++ * a .class file, a directory, or a JAR file.
++ */
++public class ClassFileReader {
++ /**
++ * Returns a ClassFileReader instance of a given path.
++ */
++ public static ClassFileReader newInstance(File path) throws IOException {
++ if (!path.exists()) {
++ throw new FileNotFoundException(path.getAbsolutePath());
++ }
++
++ if (path.isDirectory()) {
++ return new DirectoryReader(path.toPath());
++ } else if (path.getName().endsWith(".jar")) {
++ return new JarFileReader(path.toPath());
++ } else {
++ return new ClassFileReader(path.toPath());
++ }
++ }
++
++ /**
++ * Returns a ClassFileReader instance of a given JarFile.
++ */
++ public static ClassFileReader newInstance(Path path, JarFile jf) throws IOException {
++ return new JarFileReader(path, jf);
++ }
++
++ protected final Path path;
++ protected final String baseFileName;
++ private ClassFileReader(Path path) {
++ this.path = path;
++ this.baseFileName = path.getFileName() != null
++ ? path.getFileName().toString()
++ : path.toString();
++ }
++
++ public String getFileName() {
++ return baseFileName;
++ }
++
++ /**
++ * Returns the ClassFile matching the given binary name
++ * or a fully-qualified class name.
++ */
++ public ClassFile getClassFile(String name) throws IOException {
++ if (name.indexOf('.') > 0) {
++ int i = name.lastIndexOf('.');
++ String pathname = name.replace('.', File.separatorChar) + ".class";
++ if (baseFileName.equals(pathname) ||
++ baseFileName.equals(pathname.substring(0, i) + "$" +
++ pathname.substring(i+1, pathname.length()))) {
++ return readClassFile(path);
++ }
++ } else {
++ if (baseFileName.equals(name.replace('/', File.separatorChar) + ".class")) {
++ return readClassFile(path);
++ }
++ }
++ return null;
++ }
++
++ public Iterable<ClassFile> getClassFiles() throws IOException {
++ return new Iterable<ClassFile>() {
++ public Iterator<ClassFile> iterator() {
++ return new FileIterator();
++ }
++ };
++ }
++
++ protected ClassFile readClassFile(Path p) throws IOException {
++ InputStream is = null;
++ try {
++ is = Files.newInputStream(p);
++ return ClassFile.read(is);
++ } catch (ConstantPoolException e) {
++ throw new ClassFileError(e);
++ } finally {
++ if (is != null) {
++ is.close();
++ }
++ }
++ }
++
++ class FileIterator implements Iterator<ClassFile> {
++ int count;
++ FileIterator() {
++ this.count = 0;
++ }
++ public boolean hasNext() {
++ return count == 0 && baseFileName.endsWith(".class");
++ }
++
++ public ClassFile next() {
++ if (!hasNext()) {
++ throw new NoSuchElementException();
++ }
++ try {
++ ClassFile cf = readClassFile(path);
++ count++;
++ return cf;
++ } catch (IOException e) {
++ throw new ClassFileError(e);
++ }
++ }
++
++ public void remove() {
++ throw new UnsupportedOperationException("Not supported yet.");
++ }
++ }
++
++ public String toString() {
++ return path.toString();
++ }
++
++ private static class DirectoryReader extends ClassFileReader {
++ DirectoryReader(Path path) throws IOException {
++ super(path);
++ }
++
++ public ClassFile getClassFile(String name) throws IOException {
++ if (name.indexOf('.') > 0) {
++ int i = name.lastIndexOf('.');
++ String pathname = name.replace('.', File.separatorChar) + ".class";
++ Path p = path.resolve(pathname);
++ if (!p.toFile().exists()) {
++ p = path.resolve(pathname.substring(0, i) + "$" +
++ pathname.substring(i+1, pathname.length()));
++ }
++ if (p.toFile().exists()) {
++ return readClassFile(p);
++ }
++ } else {
++ Path p = path.resolve(name + ".class");
++ if (p.toFile().exists()) {
++ return readClassFile(p);
++ }
++ }
++ return null;
++ }
++
++ public Iterable<ClassFile> getClassFiles() throws IOException {
++ final Iterator<ClassFile> iter = new DirectoryIterator();
++ return new Iterable<ClassFile>() {
++ public Iterator<ClassFile> iterator() {
++ return iter;
++ }
++ };
++ }
++
++ private List<Path> walkTree(Path dir) throws IOException {
++ final List<Path> files = new ArrayList<Path>();
++ Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
++ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
++ throws IOException {
++ if (file.toFile().getName().endsWith(".class")) {
++ files.add(file);
++ }
++ return FileVisitResult.CONTINUE;
++ }
++ });
++ return files;
++ }
++
++ class DirectoryIterator implements Iterator<ClassFile> {
++ private List<Path> entries;
++ private int index = 0;
++ DirectoryIterator() throws IOException {
++ entries = walkTree(path);
++ index = 0;
++ }
++
++ public boolean hasNext() {
++ return index != entries.size();
++ }
++
++ public ClassFile next() {
++ if (!hasNext()) {
++ throw new NoSuchElementException();
++ }
++ Path path = entries.get(index++);
++ try {
++ return readClassFile(path);
++ } catch (IOException e) {
++ throw new ClassFileError(e);
++ }
++ }
++
++ public void remove() {
++ throw new UnsupportedOperationException("Not supported yet.");
++ }
++ }
++ }
++
++ private static class JarFileReader extends ClassFileReader {
++ final JarFile jarfile;
++ JarFileReader(Path path) throws IOException {
++ this(path, new JarFile(path.toFile()));
++ }
++ JarFileReader(Path path, JarFile jf) throws IOException {
++ super(path);
++ this.jarfile = jf;
++ }
++
++ public ClassFile getClassFile(String name) throws IOException {
++ if (name.indexOf('.') > 0) {
++ int i = name.lastIndexOf('.');
++ String entryName = name.replace('.', '/') + ".class";
++ JarEntry e = jarfile.getJarEntry(entryName);
++ if (e == null) {
++ e = jarfile.getJarEntry(entryName.substring(0, i) + "$"
++ + entryName.substring(i + 1, entryName.length()));
++ }
++ if (e != null) {
++ return readClassFile(e);
++ }
++ } else {
++ JarEntry e = jarfile.getJarEntry(name + ".class");
++ if (e != null) {
++ return readClassFile(e);
++ }
++ }
++ return null;
++ }
++
++ private ClassFile readClassFile(JarEntry e) throws IOException {
++ InputStream is = null;
++ try {
++ is = jarfile.getInputStream(e);
++ return ClassFile.read(is);
++ } catch (ConstantPoolException ex) {
++ throw new IOException(ex);
++ } finally {
++ if (is != null)
++ is.close();
++ }
++ }
++
++ public Iterable<ClassFile> getClassFiles() throws IOException {
++ final Iterator<ClassFile> iter = new JarFileIterator();
++ return new Iterable<ClassFile>() {
++ public Iterator<ClassFile> iterator() {
++ return iter;
++ }
++ };
++ }
++
++ class JarFileIterator implements Iterator<ClassFile> {
++ private Enumeration<JarEntry> entries;
++ private JarEntry nextEntry;
++ JarFileIterator() {
++ this.entries = jarfile.entries();
++ while (entries.hasMoreElements()) {
++ JarEntry e = entries.nextElement();
++ String name = e.getName();
++ if (name.endsWith(".class")) {
++ this.nextEntry = e;
++ break;
++ }
++ }
++ }
++
++ public boolean hasNext() {
++ return nextEntry != null;
++ }
++
++ public ClassFile next() {
++ if (!hasNext()) {
++ throw new NoSuchElementException();
++ }
++
++ ClassFile cf;
++ try {
++ cf = readClassFile(nextEntry);
++ } catch (IOException e) {
++ throw new ClassFileError(e);
++ }
++ JarEntry entry = nextEntry;
++ nextEntry = null;
++ while (entries.hasMoreElements()) {
++ JarEntry e = entries.nextElement();
++ String name = e.getName();
++ if (name.endsWith(".class")) {
++ nextEntry = e;
++ break;
++ }
++ }
++ return cf;
++ }
++
++ public void remove() {
++ throw new UnsupportedOperationException("Not supported yet.");
++ }
++ }
++ }
++
++ public static class ClassFileError extends Error {
++ public ClassFileError(Throwable t) {
++ super(t);
++ }
++ }
++}
+diff -r e56220b54fe2 -r d206cb658a99 test/sun/reflect/CallerSensitive/MethodFinder.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/sun/reflect/CallerSensitive/MethodFinder.java Mon Oct 21 18:05:56 2013 +0100
+@@ -0,0 +1,201 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++import java.util.*;
++import com.sun.tools.classfile.*;
++import static com.sun.tools.classfile.ConstantPool.*;
++import com.sun.tools.classfile.Instruction.TypeKind;
++
++/**
++ * MethodFinder utility class to find references to the given methods.
++ */
++public abstract class MethodFinder {
++ final List<String> methods;
++ public MethodFinder(String... methods) {
++ this.methods = Arrays.asList(methods);
++ }
++
++ /**
++ * A callback method will be invoked when a method referencing
++ * any of the lookup methods.
++ *
++ * @param cf ClassFile
++ * @param m Method
++ * @param refs Set of constant pool indices that reference the methods
++ * matching the given lookup method names
++ */
++ public abstract void referenceFound(ClassFile cf, Method m, Set<Integer> refs)
++ throws ConstantPoolException;
++
++ public String parse(ClassFile cf) throws ConstantPoolException {
++ List<Integer> cprefs = new ArrayList<Integer>();
++ int index = 1;
++ for (ConstantPool.CPInfo cpInfo : cf.constant_pool.entries()) {
++ if (cpInfo.accept(cpVisitor, null)) {
++ cprefs.add(index);
++ }
++ index += cpInfo.size();
++ }
++
++ if (!cprefs.isEmpty()) {
++ for (Method m : cf.methods) {
++ Set<Integer> refs = new HashSet<Integer>();
++ Code_attribute c_attr = (Code_attribute) m.attributes.get(Attribute.Code);
++ if (c_attr != null) {
++ for (Instruction instr : c_attr.getInstructions()) {
++ int idx = instr.accept(codeVisitor, cprefs);
++ if (idx > 0) {
++ refs.add(idx);
++ }
++ }
++ }
++ if (refs.size() > 0) {
++ referenceFound(cf, m, refs);
++ }
++ }
++ }
++ return cprefs.isEmpty() ? "" : cf.getName();
++ }
++
++ private ConstantPool.Visitor<Boolean,Void> cpVisitor =
++ new ConstantPool.Visitor<Boolean,Void>()
++ {
++ private boolean matches(CPRefInfo info) {
++ try {
++ CONSTANT_NameAndType_info nat = info.getNameAndTypeInfo();
++ return matches(info.getClassName(), nat.getName(), nat.getType());
++ } catch (ConstantPoolException ex) {
++ return false;
++ }
++ }
++
++ private boolean matches(String cn, String name, String type) {
++ return methods.contains(cn + "." + name);
++ }
++
++ public Boolean visitClass(CONSTANT_Class_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) {
++ return matches(info);
++ }
++
++ public Boolean visitMethodref(CONSTANT_Methodref_info info, Void p) {
++ return matches(info);
++ }
++
++ public Boolean visitDouble(CONSTANT_Double_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitFieldref(CONSTANT_Fieldref_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitFloat(CONSTANT_Float_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitInteger(CONSTANT_Integer_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitLong(CONSTANT_Long_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitNameAndType(CONSTANT_NameAndType_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitMethodHandle(CONSTANT_MethodHandle_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitMethodType(CONSTANT_MethodType_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitString(CONSTANT_String_info info, Void p) {
++ return false;
++ }
++
++ public Boolean visitUtf8(CONSTANT_Utf8_info info, Void p) {
++ return false;
++ }
++ };
++
++ private Instruction.KindVisitor<Integer, List<Integer>> codeVisitor =
++ new Instruction.KindVisitor<Integer, List<Integer>>()
++ {
++ public Integer visitNoOperands(Instruction instr, List<Integer> p) {
++ return 0;
++ }
++
++ public Integer visitArrayType(Instruction instr, TypeKind kind, List<Integer> p) {
++ return 0;
++ }
++
++ public Integer visitBranch(Instruction instr, int offset, List<Integer> p) {
++ return 0;
++ }
++
++ public Integer visitConstantPoolRef(Instruction instr, int index, List<Integer> p) {
++ return p.contains(index) ? index : 0;
++ }
++
++ public Integer visitConstantPoolRefAndValue(Instruction instr, int index, int value, List<Integer> p) {
++ return p.contains(index) ? index : 0;
++ }
++
++ public Integer visitLocal(Instruction instr, int index, List<Integer> p) {
++ return 0;
++ }
++
++ public Integer visitLocalAndValue(Instruction instr, int index, int value, List<Integer> p) {
++ return 0;
++ }
++
++ public Integer visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, List<Integer> p) {
++ return 0;
++ }
++
++ public Integer visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, List<Integer> p) {
++ return 0;
++ }
++
++ public Integer visitValue(Instruction instr, int value, List<Integer> p) {
++ return 0;
++ }
++
++ public Integer visitUnknown(Instruction instr, List<Integer> p) {
++ return 0;
++ }
++ };
++}
++
+diff -r e56220b54fe2 -r d206cb658a99 test/sun/reflect/CallerSensitive/MissingCallerSensitive.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/sun/reflect/CallerSensitive/MissingCallerSensitive.java Mon Oct 21 18:05:56 2013 +0100
+@@ -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.
++ *
++ * 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 8010117
++ * @summary Test CallerSensitiveFinder to find missing annotation
++ * @compile -XDignore.symbol.file MissingCallerSensitive.java
++ * @build CallerSensitiveFinder MethodFinder ClassFileReader
++ * @run main/othervm MissingCallerSensitive
++ */
++
++import java.nio.file.Path;
++import java.nio.file.Paths;
++import java.util.*;
++public class MissingCallerSensitive {
++ public static void main(String[] args) throws Exception {
++ String testclasses = System.getProperty("test.classes", ".");
++ List<Path> classes = new ArrayList<>();
++ classes.add(Paths.get(testclasses, "MissingCallerSensitive.class"));
++
++ final String method = "sun/reflect/Reflection.getCallerClass";
++ CallerSensitiveFinder csfinder = new CallerSensitiveFinder(method);
++ List<String> errors = csfinder.run(classes);
++ /*
++ * Expected 1 method missing @CallerSenitive and 2 methods not in
++ * the MethodHandleNatives CS list
++ */
++ if (errors.size() != 3) {
++ throw new RuntimeException("Unexpected number of methods found: " + errors.size());
++ }
++ int count=0;
++ for (String e : errors) {
++ if (e.startsWith("MissingCallerSensitive#missingCallerSensitiveAnnotation ")) {
++ count++;
++ }
++ }
++ if (count != 2) {
++ throw new RuntimeException("Error: expected 1 method missing annotation & missing in the list");
++ }
++ }
++
++ @sun.reflect.CallerSensitive
++ public ClassLoader getCallerLoader() {
++ Class<?> c = sun.reflect.Reflection.getCallerClass();
++ return c.getClassLoader();
++ }
++
++ public ClassLoader missingCallerSensitiveAnnotation() {
++ Class<?> c = sun.reflect.Reflection.getCallerClass();
++ return c.getClassLoader();
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8010727-empty_logger_name.patch b/java/openjdk6/files/icedtea/openjdk/8010727-empty_logger_name.patch
new file mode 100644
index 000000000000..307cd6877ba6
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8010727-empty_logger_name.patch
@@ -0,0 +1,101 @@
+# HG changeset patch
+# User mchung
+# Date 1368544028 25200
+# Tue May 14 08:07:08 2013 -0700
+# Node ID e3eae7996a478cd07125110456836a42c8a504c6
+# Parent d4fca2113b280a7db03b67caae22e0ceafb51b89
+8010727: WLS fails to add a logger with "" in its own LogManager subclass instance
+Reviewed-by: alanb, jgish
+
+diff -r d4fca2113b28 -r e3eae7996a47 src/share/classes/java/util/logging/LogManager.java
+--- jdk/src/share/classes/java/util/logging/LogManager.java Fri Oct 25 17:51:03 2013 +0100
++++ jdk/src/share/classes/java/util/logging/LogManager.java Tue May 14 08:07:08 2013 -0700
+@@ -486,7 +486,7 @@
+ }
+
+ synchronized void ensureRootLogger(Logger logger) {
+- if (logger == manager.rootLogger)
++ if (logger.getName().isEmpty())
+ return;
+
+ // during initialization, rootLogger is null when
+diff -r d4fca2113b28 -r e3eae7996a47 test/java/util/logging/LogManagerInstanceTest.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/LogManagerInstanceTest.java Tue May 14 08:07:08 2013 -0700
+@@ -0,0 +1,76 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++import java.util.logging.*;
++
++/*
++ * @test
++ * @bug 8010727
++ * @summary LogManager.addLogger should succeed to add a logger named ""
++ * if LogManager.getLogger("") returns null.
++ *
++ * @run main LogManagerInstanceTest
++ */
++
++public class LogManagerInstanceTest {
++ public static void main(String[] argv) {
++ LogManager mgr = LogManager.getLogManager();
++ if (getRootLogger(mgr) == null) {
++ throw new RuntimeException("Root logger not exist");
++ }
++
++ SecondLogManager mgr2 = new SecondLogManager();
++ Logger root = getRootLogger(mgr2);
++ if (mgr2.base != root) {
++ throw new RuntimeException(mgr2.base + " is not the root logger");
++ }
++ }
++
++ private static Logger getRootLogger(LogManager mgr) {
++ Logger l = mgr.getLogger("");
++ if (l != null && !l.getName().isEmpty()) {
++ throw new RuntimeException(l.getName() + " is not an invalid root logger");
++ }
++ return l;
++ }
++
++ static class SecondLogManager extends LogManager {
++ final Logger base;
++ private SecondLogManager() {
++ Logger root = getLogger("");
++ if (root == null) {
++ root = new BaseLogger("", null);
++ if (!super.addLogger(root))
++ throw new RuntimeException("Fail to addLogger " + root);
++ } else {
++ System.out.println("Root logger already exists");
++ }
++ this.base = root;
++ }
++ }
++ static class BaseLogger extends Logger {
++ BaseLogger(String name, String rbname) {
++ super(name, rbname);
++ }
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8010939-logmanager_deadlock.patch b/java/openjdk6/files/icedtea/openjdk/8010939-logmanager_deadlock.patch
new file mode 100644
index 000000000000..5bf8a341ebf8
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8010939-logmanager_deadlock.patch
@@ -0,0 +1,266 @@
+# HG changeset patch
+# User jgish
+# Date 1366415410 25200
+# Fri Apr 19 16:50:10 2013 -0700
+# Node ID ed410e3d08fe7792e6c08e411580564d2562c03e
+# Parent e3eae7996a478cd07125110456836a42c8a504c6
+8010939: Deadlock in LogManager
+Summary: re-order locks to avoid deadlock
+Reviewed-by: mchung, alanb
+
+diff -r e3eae7996a47 -r ed410e3d08fe src/share/classes/java/util/logging/LogManager.java
+--- jdk/src/share/classes/java/util/logging/LogManager.java Tue May 14 08:07:08 2013 -0700
++++ jdk/src/share/classes/java/util/logging/LogManager.java Fri Apr 19 16:50:10 2013 -0700
+@@ -33,10 +33,8 @@
+ import java.lang.ref.WeakReference;
+ import java.beans.PropertyChangeListener;
+ import java.beans.PropertyChangeSupport;
+-import java.net.URL;
+ import sun.misc.JavaAWTAccess;
+ import sun.misc.SharedSecrets;
+-import sun.security.action.GetPropertyAction;
+
+ /**
+ * There is a single global LogManager object that is used to
+@@ -151,7 +149,6 @@
+ // The global LogManager object
+ private static LogManager manager;
+
+- private final static Handler[] emptyHandlers = { };
+ private Properties props = new Properties();
+ private PropertyChangeSupport changes
+ = new PropertyChangeSupport(LogManager.class);
+@@ -506,14 +503,11 @@
+ throw new NullPointerException();
+ }
+
+- // cleanup some Loggers that have been GC'ed
+- manager.drainLoggerRefQueueBounded();
+-
+ LoggerWeakRef ref = namedLoggers.get(name);
+ if (ref != null) {
+ if (ref.get() == null) {
+- // It's possible that the Logger was GC'ed after the
+- // drainLoggerRefQueueBounded() call above so allow
++ // It's possible that the Logger was GC'ed after a
++ // drainLoggerRefQueueBounded() call so allow
+ // a new one to be registered.
+ removeLogger(name);
+ } else {
+@@ -561,6 +555,8 @@
+ return true;
+ }
+
++ // note: all calls to removeLogger are synchronized on LogManager's
++ // intrinsic lock
+ void removeLogger(String name) {
+ namedLoggers.remove(name);
+ }
+@@ -845,6 +841,7 @@
+ if (name == null) {
+ throw new NullPointerException();
+ }
++ drainLoggerRefQueueBounded();
+ LoggerContext cx = getUserContext();
+ if (cx.addLocalLogger(logger)) {
+ // Do we have a per logger handler too?
+diff -r e3eae7996a47 -r ed410e3d08fe test/java/util/logging/DrainFindDeadlockTest.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/DrainFindDeadlockTest.java Fri Apr 19 16:50:10 2013 -0700
+@@ -0,0 +1,196 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++import java.lang.management.ThreadInfo;
++import java.lang.management.ThreadMXBean;
++import java.lang.Thread.State;
++import java.io.IOException;
++import java.lang.management.ManagementFactory;
++import java.util.logging.LogManager;
++import java.util.logging.Logger;
++import java.util.Map;
++
++/**
++ * @test
++ * @bug 8010939
++ * @summary check for deadlock between findLogger() and drainLoggerRefQueueBounded()
++ * @author jim.gish@oracle.com
++ * @build DrainFindDeadlockTest
++ * @run main/othervm/timeout=10 DrainFindDeadlockTest
++ */
++
++/**
++ * This test is checking for a deadlock between
++ * LogManager$LoggerContext.findLogger() and
++ * LogManager.drainLoggerRefQueueBounded() (which could happen by calling
++ * Logger.getLogger() and LogManager.readConfiguration() in different threads)
++ */
++public class DrainFindDeadlockTest {
++ private LogManager mgr = LogManager.getLogManager();
++ private final static int MAX_ITERATIONS = 100;
++
++ // Get a ThreadMXBean so we can check for deadlock. N.B. this may
++ // not be supported on all platforms, which means we will have to
++ // resort to the traditional test timeout method. However, if
++ // we have the support we'll get the deadlock details if one
++ // is detected.
++ private final static ThreadMXBean threadMXBean =
++ ManagementFactory.getThreadMXBean();
++ private final boolean threadMXBeanDeadlockSupported =
++ threadMXBean.isSynchronizerUsageSupported();
++
++ public static void main(String... args) throws IOException, Exception {
++ new DrainFindDeadlockTest().testForDeadlock();
++ }
++
++ public static void randomDelay() {
++ int runs = (int) Math.random() * 1000000;
++ int c = 0;
++
++ for (int i=0; i<runs; ++i) {
++ c=c+i;
++ }
++ }
++
++ public void testForDeadlock() throws IOException, Exception {
++ System.out.println("Deadlock detection "
++ + (threadMXBeanDeadlockSupported ? "is" : "is not") +
++ " available.");
++ Thread setup = new Thread(new SetupLogger(), "SetupLogger");
++ Thread readConfig = new Thread(new ReadConfig(), "ReadConfig");
++ Thread check = new Thread(new DeadlockChecker(setup, readConfig),
++ "DeadlockChecker");
++
++ // make the threads daemon threads so they will go away when the
++ // test exits
++ setup.setDaemon(true);
++ readConfig.setDaemon(true);
++ check.setDaemon(true);
++
++ check.start(); setup.start(); readConfig.start();
++ try {
++ check.join();
++ } catch (InterruptedException ex) {
++ ex.printStackTrace();
++ }
++ try {
++ readConfig.join();
++ setup.join();
++ } catch (InterruptedException ex) {
++ ex.printStackTrace();
++ }
++ System.out.println("Test passed");
++ }
++
++ class SetupLogger implements Runnable {
++ Logger logger = null;
++
++ @Override
++ public void run() {
++ System.out.println("Running " + Thread.currentThread().getName());
++
++ for (int i=0; i < MAX_ITERATIONS; i++) {
++ logger = Logger.getLogger("DrainFindDeadlockTest"+i);
++ DrainFindDeadlockTest.randomDelay();
++ }
++ }
++ }
++
++ class ReadConfig implements Runnable {
++ @Override
++ public void run() {
++ System.out.println("Running " + Thread.currentThread().getName());
++ for (int i=0; i < MAX_ITERATIONS; i++) {
++ try {
++ mgr.readConfiguration();
++ } catch (IOException | SecurityException ex) {
++ throw new RuntimeException("FAILED: test setup problem", ex);
++ }
++ DrainFindDeadlockTest.randomDelay();
++ }
++ }
++ }
++
++ class DeadlockChecker implements Runnable {
++ Thread t1, t2;
++
++ DeadlockChecker(Thread t1, Thread t2) {
++ this.t1 = t1;
++ this.t2 = t2;
++ }
++
++ void checkState(Thread x, Thread y) {
++ // System.out.println("checkstate");
++ boolean isXblocked = x.getState().equals(State.BLOCKED);
++ boolean isYblocked = y.getState().equals(State.BLOCKED);
++ long[] deadlockedThreads = null;
++
++ if (isXblocked && isYblocked) {
++ System.out.println("threads blocked");
++ // they are both blocked, but this doesn't necessarily mean
++ // they are deadlocked
++ if (threadMXBeanDeadlockSupported) {
++ System.out.println("checking for deadlock");
++ deadlockedThreads = threadMXBean.findDeadlockedThreads();
++ } else {
++ System.out.println("Can't check for deadlock");
++ }
++ if (deadlockedThreads != null) {
++ System.out.println("We detected a deadlock! ");
++ ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(
++ deadlockedThreads, true, true);
++ for (ThreadInfo threadInfo: threadInfos) {
++ System.out.println(threadInfo);
++ }
++ throw new RuntimeException("TEST FAILED: Deadlock detected");
++ }
++ System.out.println("We may have a deadlock");
++ Map<Thread, StackTraceElement[]> threadMap =
++ Thread.getAllStackTraces();
++ dumpStack(threadMap.get(x), x);
++ dumpStack(threadMap.get(y), y);
++ }
++ }
++
++ private void dumpStack(StackTraceElement[] aStackElt, Thread aThread) {
++ if (aStackElt != null) {
++ System.out.println("Thread:" + aThread.getName() + ": " +
++ aThread.getState());
++ for (StackTraceElement element: aStackElt) {
++ System.out.println(" " + element);
++ }
++ }
++ }
++
++ @Override
++ public void run() {
++ System.out.println("Running " + Thread.currentThread().getName());
++ for (int i=0; i < MAX_ITERATIONS*2; i++) {
++ checkState(t1, t2);
++ try {
++ Thread.sleep(10);
++ } catch (InterruptedException ex) {
++ };
++ }
++ }
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8011071-better_crypto_provider_handling.patch b/java/openjdk6/files/icedtea/openjdk/8011071-better_crypto_provider_handling.patch
new file mode 100644
index 000000000000..223355f35f53
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8011071-better_crypto_provider_handling.patch
@@ -0,0 +1,287 @@
+# HG changeset patch
+# User ascarpino
+# Date 1381846341 -3600
+# Tue Oct 15 15:12:21 2013 +0100
+# Node ID df887df12ad1543894fe79f753983754ceef5c73
+# Parent db4712506571ae3ae2d37b91e63641b18c3258f2
+8011071: Better crypto provider handling
+Reviewed-by: hawtin, valeriep
+
+diff -r db4712506571 -r df887df12ad1 src/share/classes/com/sun/crypto/provider/DHPrivateKey.java
+--- jdk/src/share/classes/com/sun/crypto/provider/DHPrivateKey.java Mon Jul 08 14:34:36 2013 +0400
++++ jdk/src/share/classes/com/sun/crypto/provider/DHPrivateKey.java Tue Oct 15 15:12:21 2013 +0100
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2007, 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
+@@ -279,22 +279,6 @@
+ return new DHParameterSpec(this.p, this.g);
+ }
+
+- public String toString() {
+- String LINE_SEP = System.getProperty("line.separator");
+-
+- StringBuffer strbuf
+- = new StringBuffer("SunJCE Diffie-Hellman Private Key:"
+- + LINE_SEP + "x:" + LINE_SEP
+- + Debug.toHexString(this.x)
+- + LINE_SEP + "p:" + LINE_SEP
+- + Debug.toHexString(this.p)
+- + LINE_SEP + "g:" + LINE_SEP
+- + Debug.toHexString(this.g));
+- if (this.l != 0)
+- strbuf.append(LINE_SEP + "l:" + LINE_SEP + " " + this.l);
+- return strbuf.toString();
+- }
+-
+ private void parseKeyBits() throws InvalidKeyException {
+ try {
+ DerInputStream in = new DerInputStream(this.key);
+diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/ec/ECPrivateKeyImpl.java
+--- jdk/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java Mon Jul 08 14:34:36 2013 +0400
++++ jdk/src/share/classes/sun/security/ec/ECPrivateKeyImpl.java Tue Oct 15 15:12:21 2013 +0100
+@@ -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
+@@ -153,12 +153,4 @@
+ throw new InvalidKeyException("Invalid EC private key", e);
+ }
+ }
+-
+- // return a string representation of this key for debugging
+- public String toString() {
+- return "Sun EC private key, " + params.getCurve().getField().getFieldSize()
+- + " bits\n private value: "
+- + s + "\n parameters: " + params;
+- }
+-
+ }
+diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/jgss/GSSCredentialImpl.java
+--- jdk/src/share/classes/sun/security/jgss/GSSCredentialImpl.java Mon Jul 08 14:34:36 2013 +0400
++++ jdk/src/share/classes/sun/security/jgss/GSSCredentialImpl.java Tue Oct 15 15:12:21 2013 +0100
+@@ -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
+@@ -630,7 +630,7 @@
+ buffer.append(element.isAcceptorCredential() ?
+ " Accept" : "");
+ buffer.append(" [");
+- buffer.append(element.toString());
++ buffer.append(element.getClass());
+ buffer.append(']');
+ } catch (GSSException e) {
+ // skip to next element
+diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/pkcs/PKCS8Key.java
+--- jdk/src/share/classes/sun/security/pkcs/PKCS8Key.java Mon Jul 08 14:34:36 2013 +0400
++++ jdk/src/share/classes/sun/security/pkcs/PKCS8Key.java Tue Oct 15 15:12:21 2013 +0100
+@@ -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
+@@ -304,17 +304,6 @@
+ return encodedKey.clone();
+ }
+
+- /*
+- * Returns a printable representation of the key
+- */
+- public String toString ()
+- {
+- HexDumpEncoder encoder = new HexDumpEncoder ();
+-
+- return "algorithm = " + algid.toString ()
+- + ", unparsed keybits = \n" + encoder.encodeBuffer (key);
+- }
+-
+ /**
+ * Initialize an PKCS8Key object from an input stream. The data
+ * on that input stream must be encoded using DER, obeying the
+diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/pkcs11/P11Key.java
+--- jdk/src/share/classes/sun/security/pkcs11/P11Key.java Mon Jul 08 14:34:36 2013 +0400
++++ jdk/src/share/classes/sun/security/pkcs11/P11Key.java Tue Oct 15 15:12:21 2013 +0100
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+@@ -542,27 +542,6 @@
+ fetchValues();
+ return coeff;
+ }
+- public String toString() {
+- fetchValues();
+- StringBuilder sb = new StringBuilder(super.toString());
+- sb.append("\n modulus: ");
+- sb.append(n);
+- sb.append("\n public exponent: ");
+- sb.append(e);
+- sb.append("\n private exponent: ");
+- sb.append(d);
+- sb.append("\n prime p: ");
+- sb.append(p);
+- sb.append("\n prime q: ");
+- sb.append(q);
+- sb.append("\n prime exponent p: ");
+- sb.append(pe);
+- sb.append("\n prime exponent q: ");
+- sb.append(qe);
+- sb.append("\n crt coefficient: ");
+- sb.append(coeff);
+- return sb.toString();
+- }
+ }
+
+ // RSA non-CRT private key
+@@ -616,15 +595,6 @@
+ fetchValues();
+ return d;
+ }
+- public String toString() {
+- fetchValues();
+- StringBuilder sb = new StringBuilder(super.toString());
+- sb.append("\n modulus: ");
+- sb.append(n);
+- sb.append("\n private exponent: ");
+- sb.append(d);
+- return sb.toString();
+- }
+ }
+
+ private static final class P11RSAPublicKey extends P11Key
+@@ -794,11 +764,6 @@
+ fetchValues();
+ return params;
+ }
+- public String toString() {
+- fetchValues();
+- return super.toString() + "\n x: " + x + "\n p: " + params.getP()
+- + "\n q: " + params.getQ() + "\n g: " + params.getG();
+- }
+ }
+
+ private static final class P11DHPrivateKey extends P11Key
+@@ -856,11 +821,6 @@
+ fetchValues();
+ return params;
+ }
+- public String toString() {
+- fetchValues();
+- return super.toString() + "\n x: " + x + "\n p: " + params.getP()
+- + "\n g: " + params.getG();
+- }
+ }
+
+ private static final class P11DHPublicKey extends P11Key
+@@ -977,12 +937,6 @@
+ fetchValues();
+ return params;
+ }
+- public String toString() {
+- fetchValues();
+- return super.toString()
+- + "\n private value: " + s
+- + "\n parameters: " + params;
+- }
+ }
+
+ private static final class P11ECPublicKey extends P11Key
+diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/provider/DSAPrivateKey.java
+--- jdk/src/share/classes/sun/security/provider/DSAPrivateKey.java Mon Jul 08 14:34:36 2013 +0400
++++ jdk/src/share/classes/sun/security/provider/DSAPrivateKey.java Tue Oct 15 15:12:21 2013 +0100
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1996, 2002, 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
+@@ -142,11 +142,6 @@
+ }
+ }
+
+- public String toString() {
+- return "Sun DSA Private Key \nparameters:" + algid + "\nx: " +
+- Debug.toHexString(x) + "\n";
+- }
+-
+ protected void parseKeyBits() throws InvalidKeyException {
+ try {
+ DerInputStream in = new DerInputStream(key);
+diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java
+--- jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java Mon Jul 08 14:34:36 2013 +0400
++++ jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java Tue Oct 15 15:12:21 2013 +0100
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2008, 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
+@@ -225,29 +225,4 @@
+ }
+ return b;
+ }
+-
+- // return a string representation of this key for debugging
+- public String toString() {
+- StringBuffer sb = new StringBuffer();
+- sb.append("Sun RSA private CRT key, ");
+- sb.append(n.bitLength());
+- sb.append(" bits\n modulus: ");
+- sb.append(n);
+- sb.append("\n public exponent: ");
+- sb.append(e);
+- sb.append("\n private exponent: ");
+- sb.append(d);
+- sb.append("\n prime p: ");
+- sb.append(p);
+- sb.append("\n prime q: ");
+- sb.append(q);
+- sb.append("\n prime exponent p: ");
+- sb.append(pe);
+- sb.append("\n prime exponent q: ");
+- sb.append(qe);
+- sb.append("\n crt coefficient: ");
+- sb.append(coeff);
+- return sb.toString();
+- }
+-
+ }
+diff -r db4712506571 -r df887df12ad1 src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java
+--- jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java Mon Jul 08 14:34:36 2013 +0400
++++ jdk/src/share/classes/sun/security/rsa/RSAPrivateKeyImpl.java Tue Oct 15 15:12:21 2013 +0100
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2008, 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
+@@ -98,11 +98,4 @@
+ public BigInteger getPrivateExponent() {
+ return d;
+ }
+-
+- // return a string representation of this key for debugging
+- public String toString() {
+- return "Sun RSA private key, " + n.bitLength() + " bits\n modulus: "
+- + n + "\n private exponent: " + d;
+- }
+-
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8011081-improve_jhat.patch b/java/openjdk6/files/icedtea/openjdk/8011081-improve_jhat.patch
new file mode 100644
index 000000000000..1c73a4b5df09
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8011081-improve_jhat.patch
@@ -0,0 +1,267 @@
+# HG changeset patch
+# User jbachorik
+# Date 1366702651 -7200
+# Tue Apr 23 09:37:31 2013 +0200
+# Node ID de77043ae6b9c9693ae149d0ab9bae4d5007ce19
+# Parent df887df12ad1543894fe79f753983754ceef5c73
+8011081: Improve jhat
+Summary: Properly escape HTML output
+Reviewed-by: alanb, mschoene, sundar
+
+diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java
+--- jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java Tue Oct 15 15:12:21 2013 +0100
++++ jdk/src/share/classes/com/sun/tools/hat/internal/server/AllClassesQuery.java Tue Apr 23 09:37:31 2013 +0200
+@@ -84,7 +84,7 @@
+ lastPackage = pkg;
+ printClass(clazz);
+ if (clazz.getId() != -1) {
+- out.print(" [" + clazz.getIdString() + "]");
++ print(" [" + clazz.getIdString() + "]");
+ }
+ out.println("<br>");
+ }
+diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java
+--- jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java Tue Oct 15 15:12:21 2013 +0100
++++ jdk/src/share/classes/com/sun/tools/hat/internal/server/ClassQuery.java Tue Apr 23 09:37:31 2013 +0200
+@@ -112,12 +112,12 @@
+ out.println("<h2>Instances</h2>");
+
+ printAnchorStart();
+- out.print("instances/" + encodeForURL(clazz));
++ print("instances/" + encodeForURL(clazz));
+ out.print("\">");
+ out.println("Exclude subclasses</a><br>");
+
+ printAnchorStart();
+- out.print("allInstances/" + encodeForURL(clazz));
++ print("allInstances/" + encodeForURL(clazz));
+ out.print("\">");
+ out.println("Include subclasses</a><br>");
+
+@@ -126,19 +126,19 @@
+ out.println("<h2>New Instances</h2>");
+
+ printAnchorStart();
+- out.print("newInstances/" + encodeForURL(clazz));
++ print("newInstances/" + encodeForURL(clazz));
+ out.print("\">");
+ out.println("Exclude subclasses</a><br>");
+
+ printAnchorStart();
+- out.print("allNewInstances/" + encodeForURL(clazz));
++ print("allNewInstances/" + encodeForURL(clazz));
+ out.print("\">");
+ out.println("Include subclasses</a><br>");
+ }
+
+ out.println("<h2>References summary by Type</h2>");
+ printAnchorStart();
+- out.print("refsByType/" + encodeForURL(clazz));
++ print("refsByType/" + encodeForURL(clazz));
+ out.print("\">");
+ out.println("References summary by type</a>");
+
+diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java
+--- jdk/src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java Tue Oct 15 15:12:21 2013 +0100
++++ jdk/src/share/classes/com/sun/tools/hat/internal/server/HttpReader.java Tue Apr 23 09:37:31 2013 +0200
+@@ -41,21 +41,17 @@
+
+
+ import java.net.Socket;
+-import java.net.ServerSocket;
+-import java.net.InetAddress;
+
+ import java.io.InputStream;
+ import java.io.BufferedInputStream;
+ import java.io.IOException;
+-import java.io.Writer;
+ import java.io.BufferedWriter;
+ import java.io.PrintWriter;
+-import java.io.OutputStream;
+ import java.io.OutputStreamWriter;
+-import java.io.BufferedOutputStream;
+
+ import com.sun.tools.hat.internal.model.Snapshot;
+ import com.sun.tools.hat.internal.oql.OQLEngine;
++import com.sun.tools.hat.internal.util.Misc;
+
+ public class HttpReader implements Runnable {
+
+@@ -87,7 +83,7 @@
+ outputError("Protocol error");
+ }
+ int data;
+- StringBuffer queryBuf = new StringBuffer();
++ StringBuilder queryBuf = new StringBuilder();
+ while ((data = in.read()) != -1 && data != ' ') {
+ char ch = (char) data;
+ queryBuf.append(ch);
+@@ -217,7 +213,7 @@
+ private void outputError(String msg) {
+ out.println();
+ out.println("<html><body bgcolor=\"#ffffff\">");
+- out.println(msg);
++ out.println(Misc.encodeHtml(msg));
+ out.println("</body></html>");
+ }
+
+diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java
+--- jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java Tue Oct 15 15:12:21 2013 +0100
++++ jdk/src/share/classes/com/sun/tools/hat/internal/server/InstancesCountQuery.java Tue Apr 23 09:37:31 2013 +0200
+@@ -102,7 +102,7 @@
+ int count = clazz.getInstancesCount(false);
+ print("" + count);
+ printAnchorStart();
+- out.print("instances/" + encodeForURL(classes[i]));
++ print("instances/" + encodeForURL(classes[i]));
+ out.print("\"> ");
+ if (count == 1) {
+ print("instance");
+@@ -121,7 +121,7 @@
+ }
+ print("(");
+ printAnchorStart();
+- out.print("newInstances/" + encodeForURL(classes[i]));
++ print("newInstances/" + encodeForURL(classes[i]));
+ out.print("\">");
+ print("" + newInst + " new");
+ out.print("</a>) ");
+diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java
+--- jdk/src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java Tue Oct 15 15:12:21 2013 +0100
++++ jdk/src/share/classes/com/sun/tools/hat/internal/server/OQLHelp.java Tue Apr 23 09:37:31 2013 +0200
+@@ -54,10 +54,7 @@
+ out.print((char)ch);
+ }
+ } catch (Exception exp) {
+- out.println(exp.getMessage());
+- out.println("<pre>");
+- exp.printStackTrace(out);
+- out.println("</pre>");
++ printException(exp);
+ }
+ }
+ }
+diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java
+--- jdk/src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java Tue Oct 15 15:12:21 2013 +0100
++++ jdk/src/share/classes/com/sun/tools/hat/internal/server/OQLQuery.java Tue Apr 23 09:37:31 2013 +0200
+@@ -32,10 +32,7 @@
+
+ package com.sun.tools.hat.internal.server;
+
+-import com.sun.tools.hat.internal.model.*;
+ import com.sun.tools.hat.internal.oql.*;
+-import com.sun.tools.hat.internal.util.ArraySorter;
+-import com.sun.tools.hat.internal.util.Comparer;
+
+ /**
+ * This handles Object Query Language (OQL) queries.
+@@ -68,7 +65,7 @@
+ out.println("<p align='center'>");
+ out.println("<textarea name='query' cols=80 rows=10>");
+ if (oql != null) {
+- out.println(oql);
++ println(oql);
+ }
+ out.println("</textarea>");
+ out.println("</p>");
+@@ -91,10 +88,7 @@
+ try {
+ out.println(engine.toHtml(o));
+ } catch (Exception e) {
+- out.println(e.getMessage());
+- out.println("<pre>");
+- e.printStackTrace(out);
+- out.println("</pre>");
++ printException(e);
+ }
+ out.println("</td></tr>");
+ return false;
+@@ -102,10 +96,7 @@
+ });
+ out.println("</table>");
+ } catch (OQLException exp) {
+- out.println(exp.getMessage());
+- out.println("<pre>");
+- exp.printStackTrace(out);
+- out.println("</pre>");
++ printException(exp);
+ }
+ }
+
+diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java
+--- jdk/src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java Tue Oct 15 15:12:21 2013 +0100
++++ jdk/src/share/classes/com/sun/tools/hat/internal/server/QueryHandler.java Tue Apr 23 09:37:31 2013 +0200
+@@ -36,6 +36,7 @@
+
+ import com.sun.tools.hat.internal.model.*;
+ import com.sun.tools.hat.internal.util.Misc;
++import java.io.StringWriter;
+
+ import java.net.URLEncoder;
+ import java.io.UnsupportedEncodingException;
+@@ -96,7 +97,7 @@
+ }
+
+ protected void error(String msg) {
+- out.println(msg);
++ println(msg);
+ }
+
+ protected void printAnchorStart() {
+@@ -160,7 +161,6 @@
+ out.println("null");
+ return;
+ }
+- String name = clazz.getName();
+ printAnchorStart();
+ out.print("class/");
+ print(encodeForURL(clazz));
+@@ -208,6 +208,15 @@
+ }
+ }
+
++ protected void printException(Throwable t) {
++ println(t.getMessage());
++ out.println("<pre>");
++ StringWriter sw = new StringWriter();
++ t.printStackTrace(new PrintWriter(sw));
++ print(sw.toString());
++ out.println("</pre>");
++ }
++
+ protected void printHex(long addr) {
+ if (snapshot.getIdentifierSize() == 4) {
+ out.print(Misc.toHex((int)addr));
+@@ -223,4 +232,8 @@
+ protected void print(String str) {
+ out.print(Misc.encodeHtml(str));
+ }
++
++ protected void println(String str) {
++ out.println(Misc.encodeHtml(str));
++ }
+ }
+diff -r df887df12ad1 -r de77043ae6b9 src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java
+--- jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java Tue Oct 15 15:12:21 2013 +0100
++++ jdk/src/share/classes/com/sun/tools/hat/internal/server/RefsByTypeQuery.java Tue Apr 23 09:37:31 2013 +0200
+@@ -89,7 +89,7 @@
+ out.println("<p align='center'>");
+ printClass(clazz);
+ if (clazz.getId() != -1) {
+- out.println("[" + clazz.getIdString() + "]");
++ println("[" + clazz.getIdString() + "]");
+ }
+ out.println("</p>");
+
+@@ -125,9 +125,9 @@
+ JavaClass clazz = classes[i];
+ out.println("<tr><td>");
+ out.print("<a href='/refsByType/");
+- out.print(clazz.getIdString());
++ print(clazz.getIdString());
+ out.print("'>");
+- out.print(clazz.getName());
++ print(clazz.getName());
+ out.println("</a>");
+ out.println("</td><td>");
+ out.println(map.get(clazz));
diff --git a/java/openjdk6/files/icedtea/openjdk/8011139-revise_checking_getenclosingclass.patch b/java/openjdk6/files/icedtea/openjdk/8011139-revise_checking_getenclosingclass.patch
new file mode 100644
index 000000000000..90f89ce09c19
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8011139-revise_checking_getenclosingclass.patch
@@ -0,0 +1,58 @@
+# HG changeset patch
+# User jfranck
+# Date 1382726704 -3600
+# Fri Oct 25 19:45:04 2013 +0100
+# Node ID a2b63addc0633a5ef8d196d1019d78b920cb4b1a
+# Parent e7ed5dad88eefc49130ae02bcbf329d72f18f12e
+8011139: (reflect) Revise checking in getEnclosingClass
+Reviewed-by: darcy, mchung, ahgross
+
+diff -r e7ed5dad88ee -r a2b63addc063 src/share/classes/java/lang/Class.java
+--- jdk/src/share/classes/java/lang/Class.java Fri Oct 25 19:37:20 2013 +0100
++++ jdk/src/share/classes/java/lang/Class.java Fri Oct 25 19:45:04 2013 +0100
+@@ -1131,13 +1131,9 @@
+ 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,
+- Reflection.getCallerClass(), true);
+- }
++ if (enclosingCandidate != null)
++ enclosingCandidate.checkPackageAccess(
++ ClassLoader.getClassLoader(Reflection.getCallerClass()), true);
+ return enclosingCandidate;
+ }
+
+@@ -2214,6 +2210,8 @@
+ * Check if client is allowed to access members. If access is denied,
+ * throw a SecurityException.
+ *
++ * This method also enforces package access.
++ *
+ * <p> Default policy: allow all clients access with normal Java access
+ * control.
+ */
+@@ -2234,7 +2232,19 @@
+ // checkMemberAccess of subclasses of SecurityManager as specified.
+ s.checkMemberAccess(this, which);
+ }
++ this.checkPackageAccess(ccl, checkProxyInterfaces);
++ }
++ }
+
++ /*
++ * Checks if a client loaded in ClassLoader ccl is allowed to access this
++ * class under the current package access policy. If access is denied,
++ * throw a SecurityException.
++ */
++ private void checkPackageAccess(final ClassLoader ccl, boolean checkProxyInterfaces) {
++ final SecurityManager s = System.getSecurityManager();
++ if (s != null) {
++ final ClassLoader cl = getClassLoader0();
+ if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) {
+
+ String name = this.getName();
diff --git a/java/openjdk6/files/icedtea/openjdk/8011157-improve_corba_portability-jdk.patch b/java/openjdk6/files/icedtea/openjdk/8011157-improve_corba_portability-jdk.patch
new file mode 100644
index 000000000000..575da017a7e2
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8011157-improve_corba_portability-jdk.patch
@@ -0,0 +1,125 @@
+# HG changeset patch
+# User msheppar
+# Date 1381849187 -3600
+# Tue Oct 15 15:59:47 2013 +0100
+# Node ID 468ec57a684409e4c7ed97be8ffa36322fb8a36b
+# Parent de77043ae6b9c9693ae149d0ab9bae4d5007ce19
+8011157: Improve CORBA portablility
+Summary: fix also reviewed by Alexander Fomin
+Reviewed-by: alanb, coffeys, skoivu
+
+diff -r de77043ae6b9 -r 468ec57a6844 make/com/sun/jmx/Makefile
+--- jdk/make/com/sun/jmx/Makefile Tue Apr 23 09:37:31 2013 +0200
++++ jdk/make/com/sun/jmx/Makefile Tue Oct 15 15:59:47 2013 +0100
+@@ -1,5 +1,5 @@
+ #
+-# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
++# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ #
+ # This code is free software; you can redistribute it and/or modify it
+@@ -126,11 +126,13 @@
+ $(RMIC) -classpath "$(CLASSDESTDIR)" \
+ -d $(CLASSDESTDIR) \
+ -iiop -v1.2 \
++ -emitPermissionCheck \
+ $(subst /,.,$(<:$(CLASSDESTDIR)/%.class=%))
+ $(RMIC) $(HOTSPOT_INTERPRETER_FLAG) -classpath "$(CLASSDESTDIR)" \
+ -d $(CLASSDESTDIR) \
+ -iiop -v1.2 \
+ -standardPackage \
++ -emitPermissionCheck \
+ $(subst /,.,$(<:$(CLASSDESTDIR)/%.class=%))
+ @$(java-vm-cleanup)
+
+diff -r de77043ae6b9 -r 468ec57a6844 src/share/classes/javax/management/modelmbean/RequiredModelMBean.java
+--- jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Tue Apr 23 09:37:31 2013 +0200
++++ jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Tue Oct 15 15:59:47 2013 +0100
+@@ -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
+@@ -299,11 +299,15 @@
+ RequiredModelMBean.class.getName(),
+ "setModelMBeanInfo(ModelMBeanInfo)",
+ "Setting ModelMBeanInfo to " + printModelMBeanInfo(mbi));
++ int noOfNotifications = 0;
++ if (mbi.getNotifications() != null) {
++ noOfNotifications = mbi.getNotifications().length;
++ }
+ MODELMBEAN_LOGGER.logp(Level.FINER,
+ RequiredModelMBean.class.getName(),
+ "setModelMBeanInfo(ModelMBeanInfo)",
+ "ModelMBeanInfo notifications has " +
+- (mbi.getNotifications()).length + " elements");
++ noOfNotifications + " elements");
+ }
+
+ modelMBeanInfo = (ModelMBeanInfo)mbi.clone();
+@@ -3001,4 +3005,5 @@
+ Void.class.getName()
+ };
+ }
++
+ }
+diff -r de77043ae6b9 -r 468ec57a6844 src/share/classes/javax/management/remote/rmi/RMIConnector.java
+--- jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java Tue Apr 23 09:37:31 2013 +0200
++++ jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java Tue Oct 15 15:59:47 2013 +0100
+@@ -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
+@@ -60,6 +60,7 @@
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
+ import java.security.PrivilegedExceptionAction;
++import java.security.PrivilegedActionException;
+ import java.security.ProtectionDomain;
+ import java.util.Arrays;
+ import java.util.Collections;
+@@ -241,10 +242,21 @@
+ //--------------------------------------------------------------------
+ // implements JMXConnector interface
+ //--------------------------------------------------------------------
++
++ /**
++ * @throws IOException if the connection could not be made because of a
++ * communication problem, or in the case of the {@code iiop} protocol,
++ * that RMI/IIOP is not supported
++ */
+ public void connect() throws IOException {
+ connect(null);
+ }
+
++ /**
++ * @throws IOException if the connection could not be made because of a
++ * communication problem, or in the case of the {@code iiop} protocol,
++ * that RMI/IIOP is not supported
++ */
+ public synchronized void connect(Map<String,?> environment)
+ throws IOException {
+ final boolean tracing = logger.traceOn();
+@@ -2334,7 +2346,16 @@
+
+ private static RMIConnection shadowIiopStub(Stub stub)
+ throws InstantiationException, IllegalAccessException {
+- Stub proxyStub = (Stub) proxyStubClass.newInstance();
++ Stub proxyStub = null;
++ try {
++ proxyStub = AccessController.doPrivileged(new PrivilegedExceptionAction<Stub>() {
++ public Stub run() throws Exception {
++ return (Stub) proxyStubClass.newInstance();
++ }
++ });
++ } catch (PrivilegedActionException e) {
++ throw new InternalError();
++ }
+ proxyStub._set_delegate(stub._get_delegate());
+ return (RMIConnection) proxyStub;
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8011157-improve_corba_portability.patch b/java/openjdk6/files/icedtea/openjdk/8011157-improve_corba_portability.patch
new file mode 100644
index 000000000000..361cd4c5a25d
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8011157-improve_corba_portability.patch
@@ -0,0 +1,183 @@
+# HG changeset patch
+# User msheppar
+# Date 1381847065 -3600
+# Tue Oct 15 15:24:25 2013 +0100
+# Node ID 9e7e1b6ab5cdf0096c9c16d991e6a982771a15f1
+# Parent 14308db8214e69d7cad09a8f4d49d421b5b13ba0
+8011157: Improve CORBA portablility
+Summary: fix also reviewed by Alexander Fomin
+Reviewed-by: alanb, coffeys, skoivu
+
+diff -r 14308db8214e -r 9e7e1b6ab5cd src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java
+--- corba/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Mon Jun 17 19:01:08 2013 +0200
++++ corba/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java Tue Oct 15 15:24:25 2013 +0100
+@@ -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
+@@ -54,7 +54,7 @@
+ /**
+ * @author Harold Carr
+ */
+-public class SelectorImpl
++class SelectorImpl
+ extends
+ Thread
+ implements
+diff -r 14308db8214e -r 9e7e1b6ab5cd src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java
+--- corba/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java Mon Jun 17 19:01:08 2013 +0200
++++ corba/src/share/classes/sun/rmi/rmic/iiop/StubGenerator.java Tue Oct 15 15:24:25 2013 +0100
+@@ -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
+@@ -34,6 +34,9 @@
+
+ import java.io.File;
+ import java.io.IOException;
++import java.io.SerializablePermission;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
+ import java.util.Vector;
+ import java.util.Hashtable;
+ import java.util.Enumeration;
+@@ -49,6 +52,7 @@
+ import com.sun.corba.se.impl.util.PackagePrefixChecker;
+ import sun.rmi.rmic.Main;
+
++
+ /**
+ * An IIOP stub/tie generator for rmic.
+ *
+@@ -78,6 +82,7 @@
+ protected boolean castArray = false;
+ protected Hashtable transactionalObjects = new Hashtable() ;
+ protected boolean POATie = false ;
++ protected boolean emitPermissionCheck = false;
+
+ /**
+ * Default constructor for Main to use.
+@@ -193,6 +198,9 @@
+ } else if (argv[i].equals("-standardPackage")) {
+ standardPackage = true;
+ argv[i] = null;
++ } else if (argv[i].equals("-emitPermissionCheck")) {
++ emitPermissionCheck = true;
++ argv[i] = null;
+ } else if (arg.equals("-xstubbase")) {
+ argv[i] = null;
+ if (++i < argv.length && argv[i] != null && !argv[i].startsWith("-")) {
+@@ -390,9 +398,22 @@
+
+ writePackageAndImports(p);
+
++// generate
++// import java.security.AccessController;
++// import java.security.PrivilegedAction;
++// import java.io.SerializablePermission;
++ if (emitPermissionCheck) {
++ p.pln("import java.security.AccessController;");
++ p.pln("import java.security.PrivilegedAction;");
++ p.pln("import java.io.SerializablePermission;");
++ p.pln();
++ p.pln();
++ }
++
+ // Declare the stub class; implement all remote interfaces.
+
+ p.p("public class " + currentClass);
++
+ p.p(" extends " + getName(stubBaseClass));
+ p.p(" implements ");
+ if (remoteInterfaces.length > 0) {
+@@ -422,6 +443,56 @@
+ writeIds( p, theType, false );
+ p.pln();
+
++ if (emitPermissionCheck) {
++
++ // produce the following generated code
++ // private static Void checkPermission() {
++ // SecurityManager sm = System.getSecurityManager();
++ // if (sm != null) {
++ // sm.checkPermission(new SerializablePermission(
++ // "enableSubclassImplementation")); // testing
++ // }
++ // return null;
++ // }
++ //
++ // private _XXXXXX_Stub(Void ignore) {
++ // }
++ //
++ // public _XXXXXX_Stub() {
++ // this(checkPermission());
++ // }
++ // where XXXXXX is the name of the remote interface
++
++ p.pln();
++ p.plnI("private static Void checkPermission() {");
++ p.plnI("SecurityManager sm = System.getSecurityManager();");
++ p.pln("if (sm != null) {");
++ p.pI();
++ p.plnI("sm.checkPermission(new SerializablePermission(");
++ p.plnI("\"enableSubclassImplementation\"));");
++ p.pO();
++ p.pO();
++ p.pOln("}");
++ p.pln("return null;");
++ p.pO();
++ p.pOln("}");
++ p.pln();
++ p.pO();
++
++ p.pI();
++ p.pln("private " + currentClass + "(Void ignore) { }");
++ p.pln();
++
++ p.plnI("public " + currentClass + "() { ");
++ p.pln("this(checkPermission());");
++ p.pOln("}");
++ p.pln();
++ }
++
++ if (!emitPermissionCheck) {
++ p.pI();
++ }
++
+ // Write the _ids() method...
+
+ p.plnI("public String[] _ids() { ");
+@@ -815,7 +886,6 @@
+ CompoundType theType) throws IOException {
+
+ // Wtite the method declaration and opening brace...
+-
+ String methodName = method.getName();
+ String methodIDLName = method.getIDLName();
+
+@@ -1631,7 +1701,7 @@
+
+ // Write data members...
+ p.pln();
+- p.pln("private " + getName(theType) + " target = null;");
++ p.pln("volatile private " + getName(theType) + " target = null;");
+ p.pln();
+
+ // Write the ids...
+@@ -1695,6 +1765,10 @@
+
+ if (remoteMethods.length > 0) {
+ p.plnI("try {");
++ p.pln(getName(theType) + " target = this.target;");
++ p.plnI("if (target == null) {");
++ p.pln("throw new java.io.IOException();");
++ p.pOln("}");
+ p.plnI(idExtInputStream + " "+in+" = ");
+ p.pln("(" + idExtInputStream + ") "+_in+";");
+ p.pO();
diff --git a/java/openjdk6/files/icedtea/openjdk/8011990-logger_test_urls.patch b/java/openjdk6/files/icedtea/openjdk/8011990-logger_test_urls.patch
new file mode 100644
index 000000000000..fa7fa70f6942
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8011990-logger_test_urls.patch
@@ -0,0 +1,58 @@
+# HG changeset patch
+# User jgish
+# Date 1366144454 14400
+# Tue Apr 16 16:34:14 2013 -0400
+# Node ID a7048970934a1425d5486e6acd0b07558be038c4
+# Parent ed410e3d08fe7792e6c08e411580564d2562c03e
+8011990: TEST_BUG: java/util/logging/bundlesearch/ResourceBundleSearchTest.java fails on Windows
+Summary: Fix URL to reliably work on all platforms
+Reviewed-by: duke
+
+diff -r ed410e3d08fe -r a7048970934a test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java
+--- jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Fri Apr 19 16:50:10 2013 -0700
++++ jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Tue Apr 16 16:34:14 2013 -0400
+@@ -21,6 +21,7 @@
+ * questions.
+ */
+
++import java.io.File;
+ import java.lang.reflect.InvocationTargetException;
+ import java.lang.reflect.Method;
+ import java.net.URL;
+@@ -45,11 +46,13 @@
+ String testClassesDir = System.getProperty("test.classes",
+ System.getProperty("user.dir"));
+ String sep = System.getProperty("file.separator");
++
+ URL[] urls = new URL[2];
+
+ // Allow for both jtreg and standalone cases here
+- urls[0] = new URL("file://" + testDir + sep + "resources" + sep);
+- urls[1] = new URL("file://" + testClassesDir + sep );
++ urls[0] = new File( testDir + sep + "resources" + sep ).toURI().toURL();
++ urls[1] = new File( testClassesDir + sep ).toURI().toURL();
++
+ System.out.println("INFO: urls[0] = " + urls[0]);
+ System.out.println("INFO: urls[1] = " + urls[1]);
+
+diff -r ed410e3d08fe -r a7048970934a test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java
+--- jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Fri Apr 19 16:50:10 2013 -0700
++++ jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Tue Apr 16 16:34:14 2013 -0400
+@@ -29,6 +29,7 @@
+ * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp
+ * @run main ResourceBundleSearchTest
+ */
++import java.io.File;
+ import java.net.URL;
+ import java.net.URLClassLoader;
+ import java.util.ArrayList;
+@@ -70,7 +71,8 @@
+ String sep = System.getProperty("file.separator");
+
+ URL[] urls = new URL[1];
+- urls[0] = new URL("file://" + testDir + sep + "resources" + sep);
++
++ urls[0] = new File( testDir + sep + "resources" + sep ).toURI().toURL();
+ URLClassLoader rbClassLoader = new URLClassLoader(urls);
+
+ // Test 1 - can we find a Logger bundle from doing a stack search?
diff --git a/java/openjdk6/files/icedtea/openjdk/8012071-better_bean_building.patch b/java/openjdk6/files/icedtea/openjdk/8012071-better_bean_building.patch
new file mode 100644
index 000000000000..4fdce36704ba
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8012071-better_bean_building.patch
@@ -0,0 +1,87 @@
+# HG changeset patch
+# User malenkov
+# Date 1381850636 -3600
+# Tue Oct 15 16:23:56 2013 +0100
+# Node ID 7a6de63e89636f3bfb5b32e2a8d1ea3df1fe2d79
+# Parent 468ec57a684409e4c7ed97be8ffa36322fb8a36b
+8012071: Better Building of Beans
+Reviewed-by: art, skoivu
+
+diff -r 468ec57a6844 -r 7a6de63e8963 src/share/classes/java/beans/Beans.java
+--- jdk/src/share/classes/java/beans/Beans.java Tue Oct 15 15:59:47 2013 +0100
++++ jdk/src/share/classes/java/beans/Beans.java Tue Oct 15 16:23:56 2013 +0100
+@@ -42,6 +42,8 @@
+ import java.io.ObjectStreamClass;
+ import java.io.StreamCorruptedException;
+
++import java.lang.reflect.Modifier;
++
+ import java.net.URL;
+
+ import java.security.AccessController;
+@@ -222,6 +224,10 @@
+ throw ex;
+ }
+
++ if (!Modifier.isPublic(cl.getModifiers())) {
++ throw new ClassNotFoundException("" + cl + " : no public access");
++ }
++
+ /*
+ * Try to instantiate the class.
+ */
+diff -r 468ec57a6844 -r 7a6de63e8963 src/share/classes/java/beans/DefaultPersistenceDelegate.java
+--- jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Tue Oct 15 15:59:47 2013 +0100
++++ jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Tue Oct 15 16:23:56 2013 +0100
+@@ -235,6 +235,9 @@
+ for(int i = 0; i < a.length; i = i + 3) {
+ try {
+ Field f = type.getField((String)a[i]);
++ if (!ReflectUtil.isPackageAccessible(f.getDeclaringClass())) {
++ continue;
++ }
+ if (f.get(null).equals(oldValue)) {
+ out.remove(oldValue);
+ out.writeExpression(new Expression(oldValue, f, "get", new Object[]{null}));
+diff -r 468ec57a6844 -r 7a6de63e8963 src/share/classes/java/beans/MetaData.java
+--- jdk/src/share/classes/java/beans/MetaData.java Tue Oct 15 15:59:47 2013 +0100
++++ jdk/src/share/classes/java/beans/MetaData.java Tue Oct 15 16:23:56 2013 +0100
+@@ -40,6 +40,7 @@
+ import java.lang.reflect.Constructor;
+ import java.lang.reflect.Field;
+ import java.lang.reflect.Method;
++import java.lang.reflect.Modifier;
+
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
+@@ -47,6 +48,7 @@
+ import java.sql.Timestamp;
+
+ import java.util.*;
++import static sun.reflect.misc.ReflectUtil.isPackageAccessible;
+
+ import javax.swing.Box;
+ import javax.swing.JLayeredPane;
+@@ -907,13 +909,15 @@
+
+ class StaticFieldsPersistenceDelegate extends PersistenceDelegate {
+ protected void installFields(Encoder out, Class<?> cls) {
+- Field fields[] = cls.getFields();
+- for(int i = 0; i < fields.length; i++) {
+- Field field = fields[i];
+- // Don't install primitives, their identity will not be preserved
+- // by wrapping.
+- if (Object.class.isAssignableFrom(field.getType())) {
+- out.writeExpression(new Expression(field, "get", new Object[]{null}));
++ if (Modifier.isPublic(cls.getModifiers()) && isPackageAccessible(cls)) {
++ Field fields[] = cls.getFields();
++ for(int i = 0; i < fields.length; i++) {
++ Field field = fields[i];
++ // Don't install primitives, their identity will not be preserved
++ // by wrapping.
++ if (Object.class.isAssignableFrom(field.getType())) {
++ out.writeExpression(new Expression(field, "get", new Object[]{null}));
++ }
+ }
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8012147-improve_tool.patch b/java/openjdk6/files/icedtea/openjdk/8012147-improve_tool.patch
new file mode 100644
index 000000000000..efa0d2a4f753
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8012147-improve_tool.patch
@@ -0,0 +1,55 @@
+# HG changeset patch
+# User erikj
+# Date 1381850834 -3600
+# Tue Oct 15 16:27:14 2013 +0100
+# Node ID 8521d2f3d9640e6516d8b71aa2f553bc4028362f
+# Parent 7a6de63e89636f3bfb5b32e2a8d1ea3df1fe2d79
+8012147: Improve tool support
+Summary: Adding libjli to jdk lib dir and removing now redundant rpath entries from executables
+Reviewed-by: alanb, dholmes, ksrini, ahgross
+
+diff -r 7a6de63e8963 -r 8521d2f3d964 make/common/Program.gmk
+--- jdk/make/common/Program.gmk Tue Oct 15 16:23:56 2013 +0100
++++ jdk/make/common/Program.gmk Tue Oct 15 16:27:14 2013 +0100
+@@ -78,17 +78,14 @@
+ ifeq ($(PLATFORM), solaris)
+ ifeq ($(ARCH_DATA_MODEL), 32)
+ LDFLAGS += -R \$$ORIGIN/../lib/$(LIBARCH)/jli
+- LDFLAGS += -R \$$ORIGIN/../jre/lib/$(LIBARCH)/jli
+ else
+ LDFLAGS += -R \$$ORIGIN/../../lib/$(LIBARCH)/jli
+- LDFLAGS += -R \$$ORIGIN/../../jre/lib/$(LIBARCH)/jli
+ endif
+ endif
+ ifeq ($(PLATFORM), linux)
+ LDFLAGS += -Wl,-z -Wl,origin
+ LDFLAGS += -Wl,--allow-shlib-undefined
+ LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli
+- LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli
+ endif
+ endif
+ ifeq ($(PLATFORM), windows)
+diff -r 7a6de63e8963 -r 8521d2f3d964 make/common/Release.gmk
+--- jdk/make/common/Release.gmk Tue Oct 15 16:23:56 2013 +0100
++++ jdk/make/common/Release.gmk Tue Oct 15 16:27:14 2013 +0100
+@@ -855,6 +855,11 @@
+ | $(CPIO) -pdum $(JDK_IMAGE_DIR)/jre )
+ $(RM) -rf $(JDK_IMAGE_DIR)/jre/man
+ $(CHMOD) a+rx `$(FIND) $(JDK_IMAGE_DIR) -type d`
++ ifneq (,$(findstring $(PLATFORM), linux solaris)) # If linux or solaris
++ ($(CD) $(LIBDIR)/.. && $(TAR) cf - \
++ `$(FIND) lib -name $(LIB_PREFIX)jli.$(LIB_SUFFIX) -print `) | \
++ ($(CD) $(JDK_IMAGE_DIR) && $(TAR) xf -)
++ endif # PLATFORM
+
+ initial-image-jdk64-bindemos:
+ for dir in bin demo ; do \
+@@ -891,7 +896,7 @@
+ initial-image-jdk:: initial-image-jdk-setup \
+ initial-image-jdk-db \
+ $(JDK_LICENSES) $(JDK_DOCFILES)
+- $(MKDIR) $(JDK_IMAGE_DIR)/lib
++ $(MKDIR) -p $(JDK_IMAGE_DIR)/lib
+ @#
+ @# Copy in the jars in lib that only belong in the JDK
+ @#
diff --git a/java/openjdk6/files/icedtea/openjdk/8012243-serial_regression.patch b/java/openjdk6/files/icedtea/openjdk/8012243-serial_regression.patch
new file mode 100644
index 000000000000..1cffb35a587b
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8012243-serial_regression.patch
@@ -0,0 +1,45 @@
+# HG changeset patch
+# User dfuchs
+# Date 1367362161 -7200
+# Wed May 01 00:49:21 2013 +0200
+# Node ID 47c881c5439a4542b19ab85f376e94fc2c0a5a57
+# Parent 0bf55b4c8a7bbea02a9d848b2a5451adbd6a6ac4
+8012243: about 30% regression on specjvm2008.serial on 7u25 comparing 7u21
+Reviewed-by: alanb, skoivu, smarks, mchung
+
+diff -r 0bf55b4c8a7b -r 47c881c5439a src/share/classes/java/io/ObjectStreamClass.java
+--- jdk/src/share/classes/java/io/ObjectStreamClass.java Fri May 17 14:29:51 2013 -0700
++++ jdk/src/share/classes/java/io/ObjectStreamClass.java Wed May 01 00:49:21 2013 +0200
+@@ -241,9 +241,11 @@
+ if (cl == null) {
+ return null;
+ }
+- Class<?> caller = Reflection.getCallerClass();
+- if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) {
+- ReflectUtil.checkPackageAccess(cl);
++ if (System.getSecurityManager() != null) {
++ Class<?> caller = Reflection.getCallerClass();
++ if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), cl.getClassLoader())) {
++ ReflectUtil.checkPackageAccess(cl);
++ }
+ }
+ return cl;
+ }
+diff -r 0bf55b4c8a7b -r 47c881c5439a src/share/classes/java/io/ObjectStreamField.java
+--- jdk/src/share/classes/java/io/ObjectStreamField.java Fri May 17 14:29:51 2013 -0700
++++ jdk/src/share/classes/java/io/ObjectStreamField.java Wed May 01 00:49:21 2013 +0200
+@@ -162,9 +162,11 @@
+ */
+ @CallerSensitive
+ public Class<?> getType() {
+- Class<?> caller = Reflection.getCallerClass();
+- if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) {
+- ReflectUtil.checkPackageAccess(type);
++ if (System.getSecurityManager() != null) {
++ Class<?> caller = Reflection.getCallerClass();
++ if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(), type.getClassLoader())) {
++ ReflectUtil.checkPackageAccess(type);
++ }
+ }
+ return type;
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8012277-improve_dataflavour.patch b/java/openjdk6/files/icedtea/openjdk/8012277-improve_dataflavour.patch
new file mode 100644
index 000000000000..d2606de4cb21
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8012277-improve_dataflavour.patch
@@ -0,0 +1,83 @@
+# HG changeset patch
+# User malenkov
+# Date 1370018612 -14400
+# Fri May 31 20:43:32 2013 +0400
+# Node ID 337232ddaec36c6d9843ff35906e6160446844eb
+# Parent 8521d2f3d9640e6516d8b71aa2f553bc4028362f
+8012277: Improve AWT DataFlavor
+Reviewed-by: art, skoivu
+
+diff -r 8521d2f3d964 -r 337232ddaec3 src/share/classes/java/awt/datatransfer/DataFlavor.java
+--- jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Tue Oct 15 16:27:14 2013 +0100
++++ jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Fri May 31 20:43:32 2013 +0400
+@@ -25,12 +25,14 @@
+
+ package java.awt.datatransfer;
+
+-import java.awt.Toolkit;
+ import java.io.*;
+ import java.nio.*;
+ import java.util.*;
+
+ import sun.awt.datatransfer.DataTransferer;
++import sun.reflect.misc.ReflectUtil;
++
++import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION;
+
+ /**
+ * A {@code DataFlavor} provides meta information about data. {@code DataFlavor}
+@@ -117,26 +119,36 @@
+ ClassLoader fallback)
+ throws ClassNotFoundException
+ {
+- ClassLoader systemClassLoader = (ClassLoader)
+- java.security.AccessController.doPrivileged(
+- new java.security.PrivilegedAction() {
+- public Object run() {
+- ClassLoader cl = Thread.currentThread().
+- getContextClassLoader();
+- return (cl != null)
+- ? cl
+- : ClassLoader.getSystemClassLoader();
++ ReflectUtil.checkPackageAccess(className);
++ try {
++ SecurityManager sm = System.getSecurityManager();
++ if (sm != null) {
++ sm.checkPermission(GET_CLASSLOADER_PERMISSION);
++ }
++ ClassLoader loader = ClassLoader.getSystemClassLoader();
++ try {
++ // bootstrap class loader and system class loader if present
++ return Class.forName(className, true, loader);
++ }
++ catch (ClassNotFoundException exception) {
++ // thread context class loader if and only if present
++ loader = Thread.currentThread().getContextClassLoader();
++ if (loader != null) {
++ try {
++ return Class.forName(className, true, loader);
+ }
+- });
+-
+- try {
+- return Class.forName(className, true, systemClassLoader);
+- } catch (ClassNotFoundException e2) {
+- if (fallback != null) {
+- return Class.forName(className, true, fallback);
+- } else {
+- throw new ClassNotFoundException(className);
++ catch (ClassNotFoundException e) {
++ // fallback to user's class loader
++ }
++ }
+ }
++ } catch (SecurityException exception) {
++ // ignore secured class loaders
++ }
++ if (fallback != null) {
++ return Class.forName(className, true, fallback);
++ } else {
++ throw new ClassNotFoundException(className);
+ }
+ }
+
diff --git a/java/openjdk6/files/icedtea/openjdk/8012425-transform_transformfactory.patch b/java/openjdk6/files/icedtea/openjdk/8012425-transform_transformfactory.patch
new file mode 100644
index 000000000000..d2249f820043
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8012425-transform_transformfactory.patch
@@ -0,0 +1,380 @@
+# HG changeset patch
+# User joehw
+# Date 1383025844 0
+# Tue Oct 29 05:50:44 2013 +0000
+# Node ID 7799c3bd00f5a4fda6448cb8bcd7768c66ec166d
+# Parent b5b1d1fa4bb4fcd8bc0602fd4f3523fe24d9f00b
+8012425: Transform TransformerFactory
+Reviewed-by: alanb, dfuchs, mullan
+
+diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Thu Oct 10 16:18:30 2013 +0100
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Tue Oct 29 05:50:44 2013 +0000
+@@ -40,6 +40,7 @@
+ import java.util.Vector;
+ import java.lang.reflect.Constructor;
+
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.DocumentBuilder;
+ import javax.xml.parsers.DocumentBuilderFactory;
+ import javax.xml.parsers.ParserConfigurationException;
+@@ -251,6 +252,7 @@
+ _propertiesClone = (Properties) _properties.clone();
+ _indentNumber = indentNumber;
+ _tfactory = tfactory;
++ _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
+ //_isIncremental = tfactory._incremental;
+ }
+
+@@ -266,6 +268,7 @@
+ */
+ public void setSecureProcessing(boolean flag) {
+ _isSecureProcessing = flag;
++ _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
+ }
+
+ /**
+diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java Thu Oct 10 16:18:30 2013 +0100
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java Tue Oct 29 05:50:44 2013 +0000
+@@ -104,6 +104,13 @@
+ if (reader == null) {
+ try {
+ reader= XMLReaderFactory.createXMLReader();
++ try {
++ reader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
++ xsltc.isSecureProcessing());
++ } catch (SAXNotRecognizedException e) {
++ System.err.println("Warning: " + reader.getClass().getName() + ": "
++ + e.getMessage());
++ }
+ } catch (Exception e ) {
+ try {
+
+diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Thu Oct 10 16:18:30 2013 +0100
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Tue Oct 29 05:50:44 2013 +0000
+@@ -20,9 +20,18 @@
+
+ package com.sun.org.apache.xerces.internal.jaxp.validation;
+
++import com.sun.org.apache.xerces.internal.impl.Constants;
++import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
++import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
++import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
++import com.sun.org.apache.xerces.internal.util.SecurityManager;
++import com.sun.org.apache.xerces.internal.xni.XNIException;
++import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
++import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
++import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
+ import java.lang.ref.SoftReference;
+ import java.io.IOException;
+-
++import javax.xml.XMLConstants;
+ import javax.xml.transform.Result;
+ import javax.xml.transform.Source;
+ import javax.xml.transform.sax.SAXTransformerFactory;
+@@ -32,15 +41,6 @@
+ import javax.xml.transform.TransformerConfigurationException;
+ import javax.xml.transform.TransformerException;
+ import javax.xml.transform.TransformerFactoryConfigurationError;
+-
+-import com.sun.org.apache.xerces.internal.impl.Constants;
+-import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
+-import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
+-import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
+-import com.sun.org.apache.xerces.internal.xni.XNIException;
+-import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+-import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
+-import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
+ import org.xml.sax.SAXException;
+
+ /**
+@@ -84,6 +84,11 @@
+ private static final String VALIDATION_MANAGER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
+
++
++ /** Property id: security manager. */
++ private static final String SECURITY_MANAGER =
++ Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
++
+ //
+ // Data
+ //
+@@ -161,6 +166,9 @@
+
+ private XMLParserConfiguration initialize() {
+ XML11Configuration config = new XML11Configuration();
++ if (fComponentManager.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) {
++ config.setProperty(SECURITY_MANAGER, new SecurityManager());
++ }
+ config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER));
+ config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER));
+ XMLErrorReporter errorReporter = (XMLErrorReporter) fComponentManager.getProperty(ERROR_REPORTER);
+diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Thu Oct 10 16:18:30 2013 +0100
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Tue Oct 29 05:50:44 2013 +0000
+@@ -672,6 +672,8 @@
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setNamespaceAware(true);
+ try {
++ spf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
++ fComponentManager.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING));
+ reader = spf.newSAXParser().getXMLReader();
+ // If this is a Xerces SAX parser, set the security manager if there is one
+ if (reader instanceof com.sun.org.apache.xerces.internal.parsers.SAXParser) {
+diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java Thu Oct 10 16:18:30 2013 +0100
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java Tue Oct 29 05:50:44 2013 +0000
+@@ -20,15 +20,12 @@
+
+ package com.sun.org.apache.xerces.internal.parsers;
+
+-import java.io.IOException;
+-import java.util.Locale;
+-
+ import com.sun.org.apache.xerces.internal.impl.Constants;
+-import com.sun.org.apache.xerces.internal.xs.PSVIProvider;
++import com.sun.org.apache.xerces.internal.util.EntityResolver2Wrapper;
+ import com.sun.org.apache.xerces.internal.util.EntityResolverWrapper;
+-import com.sun.org.apache.xerces.internal.util.EntityResolver2Wrapper;
+ import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
+ import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
++import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.SymbolHash;
+ import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+ import com.sun.org.apache.xerces.internal.xni.Augmentations;
+@@ -47,15 +44,17 @@
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
+ import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
+ import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
++import com.sun.org.apache.xerces.internal.xs.PSVIProvider;
++import java.io.IOException;
++import java.util.Locale;
++import javax.xml.XMLConstants;
+ import org.xml.sax.AttributeList;
+-import org.xml.sax.Attributes;
+ import org.xml.sax.ContentHandler;
+ import org.xml.sax.DTDHandler;
+ import org.xml.sax.DocumentHandler;
+ import org.xml.sax.EntityResolver;
+ import org.xml.sax.ErrorHandler;
+ import org.xml.sax.InputSource;
+-import org.xml.sax.Locator;
+ import org.xml.sax.Parser;
+ import org.xml.sax.SAXException;
+ import org.xml.sax.SAXNotRecognizedException;
+@@ -129,6 +128,10 @@
+ protected static final String DOM_NODE =
+ Constants.SAX_PROPERTY_PREFIX + Constants.DOM_NODE_PROPERTY;
+
++ /** Property id: security manager. */
++ private static final String SECURITY_MANAGER =
++ Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
++
+ /** Recognized properties. */
+ private static final String[] RECOGNIZED_PROPERTIES = {
+ LEXICAL_HANDLER,
+@@ -1643,19 +1646,13 @@
+ // Drop through and perform default processing
+ //
+ }
+-
+- //
+- // Xerces Features
+- //
+-
+- /*
+- else if (featureId.startsWith(XERCES_FEATURES_PREFIX)) {
+- String feature = featureId.substring(XERCES_FEATURES_PREFIX.length());
+- //
+- // Drop through and perform default processing
+- //
++ else if (featureId.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
++ if (state) {
++ if (fConfiguration.getProperty(SECURITY_MANAGER )==null) {
++ fConfiguration.setProperty(SECURITY_MANAGER, new SecurityManager());
++ }
++ }
+ }
+- */
+
+ //
+ // Default handling
+diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Thu Oct 10 16:18:30 2013 +0100
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Tue Oct 29 05:50:44 2013 +0000
+@@ -20,11 +20,6 @@
+
+ package com.sun.org.apache.xerces.internal.parsers;
+
+-import java.io.IOException;
+-import java.util.ArrayList;
+-import java.util.HashMap;
+-import java.util.Locale;
+-
+ import com.sun.org.apache.xerces.internal.impl.Constants;
+ import com.sun.org.apache.xerces.internal.impl.XML11DTDScannerImpl;
+ import com.sun.org.apache.xerces.internal.impl.XML11DocumentScannerImpl;
+@@ -65,6 +60,11 @@
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration;
++import java.io.IOException;
++import java.util.ArrayList;
++import java.util.HashMap;
++import java.util.Locale;
++import javax.xml.XMLConstants;
+
+ /**
+ * This class is the configuration used to parse XML 1.0 and XML 1.1 documents.
+@@ -428,30 +428,30 @@
+ XMLGrammarPool grammarPool,
+ XMLComponentManager parentSettings) {
+
+- super(parentSettings);
++ super(parentSettings);
+
+- // create a vector to hold all the components in use
+- // XML 1.0 specialized components
+- fComponents = new ArrayList();
+- // XML 1.1 specialized components
+- fXML11Components = new ArrayList();
+- // Common components for XML 1.1. and XML 1.0
+- fCommonComponents = new ArrayList();
++ // create a vector to hold all the components in use
++ // XML 1.0 specialized components
++ fComponents = new ArrayList();
++ // XML 1.1 specialized components
++ fXML11Components = new ArrayList();
++ // Common components for XML 1.1. and XML 1.0
++ fCommonComponents = new ArrayList();
+
+- // create storage for recognized features and properties
+- fRecognizedFeatures = new ArrayList();
+- fRecognizedProperties = new ArrayList();
+-
+- // create table for features and properties
+- fFeatures = new HashMap();
+- fProperties = new HashMap();
++ // create storage for recognized features and properties
++ fRecognizedFeatures = new ArrayList();
++ fRecognizedProperties = new ArrayList();
++
++ // create table for features and properties
++ fFeatures = new HashMap();
++ fProperties = new HashMap();
+
+ // add default recognized features
+ final String[] recognizedFeatures =
+ {
+ CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl
+- VALIDATION,
+- NAMESPACES,
++ VALIDATION,
++ NAMESPACES,
+ NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
+ GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS,
+ HONOUR_ALL_SCHEMALOCATIONS, USE_GRAMMAR_POOL_ONLY,
+@@ -460,26 +460,29 @@
+ // features might not have been set and it would cause a
+ // not-recognized exception to be thrown. -Ac
+ XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING,
+- EXTERNAL_GENERAL_ENTITIES,
+- EXTERNAL_PARAMETER_ENTITIES,
+- PARSER_SETTINGS
++ EXTERNAL_GENERAL_ENTITIES,
++ EXTERNAL_PARAMETER_ENTITIES,
++ PARSER_SETTINGS,
++ XMLConstants.FEATURE_SECURE_PROCESSING
+ };
++
+ addRecognizedFeatures(recognizedFeatures);
+ // set state for default features
+- fFeatures.put(VALIDATION, Boolean.FALSE);
+- fFeatures.put(NAMESPACES, Boolean.TRUE);
+- fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
+- fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
+- fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
+- fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
+- fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE);
+- fFeatures.put(NORMALIZE_DATA, Boolean.TRUE);
+- fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE);
++ fFeatures.put(VALIDATION, Boolean.FALSE);
++ fFeatures.put(NAMESPACES, Boolean.TRUE);
++ fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
++ fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
++ fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
++ fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
++ fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE);
++ fFeatures.put(NORMALIZE_DATA, Boolean.TRUE);
++ fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE);
+ fFeatures.put(GENERATE_SYNTHETIC_ANNOTATIONS, Boolean.FALSE);
+ fFeatures.put(VALIDATE_ANNOTATIONS, Boolean.FALSE);
+ fFeatures.put(HONOUR_ALL_SCHEMALOCATIONS, Boolean.FALSE);
+ fFeatures.put(USE_GRAMMAR_POOL_ONLY, Boolean.FALSE);
+- fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);
++ fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);
++ fFeatures.put(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+
+ // add default recognized properties
+ final String[] recognizedProperties =
+diff -r b5b1d1fa4bb4 -r 7799c3bd00f5 drop_included/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java Thu Oct 10 16:18:30 2013 +0100
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java Tue Oct 29 05:50:44 2013 +0000
+@@ -24,6 +24,7 @@
+
+ import java.util.HashMap;
+
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.FactoryConfigurationError;
+ import javax.xml.parsers.ParserConfigurationException;
+ import javax.xml.parsers.SAXParserFactory;
+@@ -31,6 +32,7 @@
+ import org.xml.sax.XMLReader;
+ import org.xml.sax.helpers.XMLReaderFactory;
+ import org.xml.sax.SAXException;
++import org.xml.sax.SAXNotRecognizedException;
+
+ /**
+ * Creates XMLReader objects and caches them for re-use.
+@@ -60,6 +62,8 @@
+ */
+ private HashMap m_inUse;
+
++
++ private boolean _secureProcessing;
+ /**
+ * Hidden constructor
+ */
+@@ -109,7 +113,12 @@
+ // TransformerFactory creates a reader via the
+ // XMLReaderFactory if setXMLReader is not used
+ reader = XMLReaderFactory.createXMLReader();
+-
++ try {
++ reader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _secureProcessing);
++ } catch (SAXNotRecognizedException e) {
++ System.err.println("Warning: " + reader.getClass().getName() + ": "
++ + e.getMessage());
++ }
+ } catch (Exception e) {
+ try {
+ // If unable to create an instance, let's try to use
+@@ -150,6 +159,15 @@
+ return reader;
+ }
+
++ /**
++ * Set feature
++ */
++ public void setFeature(String name, boolean value) {
++ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
++ _secureProcessing = value;
++ }
++ }
++
+ /**
+ * Mark the cached XMLReader as available. If the reader was not
+ * actually in the cache, do nothing.
diff --git a/java/openjdk6/files/icedtea/openjdk/8012453-runtime.exec.patch b/java/openjdk6/files/icedtea/openjdk/8012453-runtime.exec.patch
new file mode 100644
index 000000000000..143a0c1f286d
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8012453-runtime.exec.patch
@@ -0,0 +1,383 @@
+# HG changeset patch
+# User uta
+# Date 1383008821 0
+# Tue Oct 29 01:07:01 2013 +0000
+# Node ID 20c88fd14959c6a4df2e0f36bd759b56efa6f2cb
+# Parent 3e758b40337ef9da5ad030d0ac60ab4407357277
+8012453: (process) Runtime.exec(String) fails if command contains spaces [win]
+Reviewed-by: alanb
+
+diff -r 3e758b40337e -r 20c88fd14959 src/share/classes/java/lang/ProcessBuilder.java
+--- jdk/src/share/classes/java/lang/ProcessBuilder.java Tue Jul 30 17:20:22 2013 -0400
++++ jdk/src/share/classes/java/lang/ProcessBuilder.java Tue Oct 29 01:07:01 2013 +0000
+@@ -490,6 +490,15 @@
+ + (dir == null ? "" : " (in directory \"" + dir + "\")")
+ + exceptionInfo,
+ cause);
++ } catch (IllegalArgumentException e) {
++ String exceptionInfo = ": " + e.getMessage();
++ // It's much easier for us to create a high-quality error
++ // message than the low-level C code which found the problem.
++ throw new IOException(
++ "Cannot run program \"" + prog + "\""
++ + (dir == null ? "" : " (in directory \"" + dir + "\")")
++ + exceptionInfo,
++ e);
+ }
+ }
+ }
+diff -r 3e758b40337e -r 20c88fd14959 src/windows/classes/java/lang/ProcessImpl.java
+--- jdk/src/windows/classes/java/lang/ProcessImpl.java Tue Jul 30 17:20:22 2013 -0400
++++ jdk/src/windows/classes/java/lang/ProcessImpl.java Tue Oct 29 01:07:01 2013 +0000
+@@ -26,6 +26,9 @@
+ package java.lang;
+
+ import java.io.*;
++import java.util.ArrayList;
++import java.util.regex.Matcher;
++import java.util.regex.Pattern;
+
+ /* This class is for the exclusive use of ProcessBuilder.start() to
+ * create new processes.
+@@ -47,6 +50,66 @@
+ return new ProcessImpl(cmdarray, envblock, dir, redirectErrorStream);
+ }
+
++ private static class LazyPattern {
++ // Escape-support version:
++ // "(\")((?:\\\\\\1|.)+?)\\1|([^\\s\"]+)";
++ private static final Pattern PATTERN =
++ Pattern.compile("[^\\s\"]+|\"[^\"]*\"");
++ };
++
++ /* Parses the command string parameter into the executable name and
++ * program arguments.
++ *
++ * The command string is broken into tokens. The token separator is a space
++ * or quota character. The space inside quotation is not a token separator.
++ * There are no escape sequences.
++ */
++ private static String[] getTokensFromCommand(String command) {
++ ArrayList<String> matchList = new ArrayList<String>(8);
++ Matcher regexMatcher = LazyPattern.PATTERN.matcher(command);
++ while (regexMatcher.find())
++ matchList.add(regexMatcher.group());
++ return matchList.toArray(new String[matchList.size()]);
++ }
++
++ private static String createCommandLine(boolean isCmdFile,
++ final String executablePath,
++ final String cmd[])
++ {
++ StringBuilder cmdbuf = new StringBuilder(80);
++
++ cmdbuf.append(executablePath);
++
++ for (int i = 1; i < cmd.length; ++i) {
++ cmdbuf.append(' ');
++ String s = cmd[i];
++ if (needsEscaping(isCmdFile, s)) {
++ cmdbuf.append('"');
++ cmdbuf.append(s);
++
++ // The code protects the [java.exe] and console command line
++ // parser, that interprets the [\"] combination as an escape
++ // sequence for the ["] char.
++ // http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
++ //
++ // If the argument is an FS path, doubling of the tail [\]
++ // char is not a problem for non-console applications.
++ //
++ // The [\"] sequence is not an escape sequence for the [cmd.exe]
++ // command line parser. The case of the [""] tail escape
++ // sequence could not be realized due to the argument validation
++ // procedure.
++ if (!isCmdFile && s.endsWith("\\")) {
++ cmdbuf.append('\\');
++ }
++ cmdbuf.append('"');
++ } else {
++ cmdbuf.append(s);
++ }
++ }
++ return cmdbuf.toString();
++ }
++
+ // We guarantee the only command file execution for implicit [cmd.exe] run.
+ // http://technet.microsoft.com/en-us/library/bb490954.aspx
+ private static final char CMD_BAT_ESCAPE[] = {' ', '\t', '<', '>', '&', '|', '^'};
+@@ -128,6 +191,16 @@
+ return fileToRun.getPath();
+ }
+
++ private boolean isShellFile(String executablePath) {
++ String upPath = executablePath.toUpperCase();
++ return (upPath.endsWith(".CMD") || upPath.endsWith(".BAT"));
++ }
++
++ private String quoteString(String arg) {
++ StringBuilder argbuf = new StringBuilder(arg.length() + 2);
++ return argbuf.append('"').append(arg).append('"').toString();
++ }
++
+
+ private long handle = 0;
+ private FileDescriptor stdin_fd;
+@@ -143,36 +216,66 @@
+ boolean redirectErrorStream)
+ throws IOException
+ {
+- // The [executablePath] is not quoted for any case.
+- String executablePath = getExecutablePath(cmd[0]);
++ String cmdstr;
++ SecurityManager security = System.getSecurityManager();
++ boolean allowAmbigousCommands = false;
++ if (security == null) {
++ String value = System.getProperty("jdk.lang.Process.allowAmbigousCommands");
++ if (value != null)
++ allowAmbigousCommands = !"false".equalsIgnoreCase(value);
++ }
++ if (allowAmbigousCommands) {
++ // Legacy mode.
+
+- // We need to extend the argument verification procedure
+- // to guarantee the only command file execution for implicit [cmd.exe]
+- // run.
+- String upPath = executablePath.toUpperCase();
+- boolean isCmdFile = (upPath.endsWith(".CMD") || upPath.endsWith(".BAT"));
++ // Normalize path if possible.
++ String executablePath = new File(cmd[0]).getPath();
+
+- StringBuilder cmdbuf = new StringBuilder(80);
++ // No worry about internal and unpaired ["] .
++ if (needsEscaping(false, executablePath) )
++ executablePath = quoteString(executablePath);
+
+- // Quotation protects from interpretation of the [path] argument as
+- // start of longer path with spaces. Quotation has no influence to
+- // [.exe] extension heuristic.
+- cmdbuf.append('"');
+- cmdbuf.append(executablePath);
+- cmdbuf.append('"');
++ cmdstr = createCommandLine(
++ false, //legacy mode doesn't worry about extended verification
++ executablePath,
++ cmd);
++ } else {
++ String executablePath;
++ try {
++ executablePath = getExecutablePath(cmd[0]);
++ } catch (IllegalArgumentException e) {
++ // Workaround for the calls like
++ // Runtime.getRuntime().exec("\"C:\\Program Files\\foo\" bar")
+
+- for (int i = 1; i < cmd.length; i++) {
+- cmdbuf.append(' ');
+- String s = cmd[i];
+- if (needsEscaping(isCmdFile, s)) {
+- cmdbuf.append('"');
+- cmdbuf.append(s);
+- cmdbuf.append('"');
+- } else {
+- cmdbuf.append(s);
++ // No chance to avoid CMD/BAT injection, except to do the work
++ // right from the beginning. Otherwise we have too many corner
++ // cases from
++ // Runtime.getRuntime().exec(String[] cmd [, ...])
++ // calls with internal ["] and escape sequences.
++
++ // Restore original command line.
++ StringBuilder join = new StringBuilder();
++ // terminal space in command line is ok
++ for (String s : cmd)
++ join.append(s).append(' ');
++
++ // Parse the command line again.
++ cmd = getTokensFromCommand(join.toString());
++ executablePath = getExecutablePath(cmd[0]);
++
++ // Check new executable name once more
++ if (security != null)
++ security.checkExec(executablePath);
+ }
++
++ // Quotation protects from interpretation of the [path] argument as
++ // start of longer path with spaces. Quotation has no influence to
++ // [.exe] extension heuristic.
++ cmdstr = createCommandLine(
++ // We need the extended verification procedure for CMD files.
++ isShellFile(executablePath),
++ quoteString(executablePath),
++ cmd);
+ }
+- String cmdstr = cmdbuf.toString();
+
+ stdin_fd = new FileDescriptor();
+ stdout_fd = new FileDescriptor();
+diff -r 3e758b40337e -r 20c88fd14959 test/java/lang/Runtime/exec/ExecCommand.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/lang/Runtime/exec/ExecCommand.java Tue Oct 29 01:07:01 2013 +0000
+@@ -0,0 +1,163 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++
++/**
++ * @test
++ * @bug 8012453
++ * @run main/othervm ExecCommand
++ * @summary workaround for legacy applications with Runtime.getRuntime().exec(String command)
++ */
++
++import java.io.BufferedWriter;
++import java.io.File;
++import java.io.FileWriter;
++import java.io.IOException;
++import java.security.AccessControlException;
++
++public class ExecCommand {
++ static class SecurityMan extends SecurityManager {
++ public static String unquote(String str)
++ {
++ int length = (str == null)
++ ? 0
++ : str.length();
++
++ if (length > 1
++ && str.charAt(0) == '\"'
++ && str.charAt(length - 1) == '\"')
++ {
++ return str.substring(1, length - 1);
++ }
++ return str;
++ }
++
++ @Override public void checkExec(String cmd) {
++ String ncmd = (new File(unquote(cmd))).getPath();
++ if ( ncmd.equals(".\\Program")
++ || ncmd.equals("\".\\Program")
++ || ncmd.equals(".\\Program Files\\do.cmd")
++ || ncmd.equals(".\\Program.cmd"))
++ {
++ return;
++ }
++ super.checkExec(cmd);
++ }
++ }
++
++ // Parameters for the Runtime.exec calls
++ private static final String TEST_RTE_ARG[] = {
++ ".\\Program Files\\do.cmd",
++ "\".\\Program Files\\doNot.cmd\" arg",
++ "\".\\Program Files\\do.cmd\" arg",
++ // compatibility
++ "\".\\Program.cmd\" arg",
++ ".\\Program.cmd arg",
++ };
++
++ private static final String doCmdCopy[] = {
++ ".\\Program.cmd",
++ ".\\Program Files\\doNot.cmd",
++ ".\\Program Files\\do.cmd",
++ };
++
++ // Golden image for results
++ private static final String TEST_RTE_GI[][] = {
++ //Pure system | Legacy mode | Legacy mode & SM
++ // [.\Program File\do.cmd]
++ new String[]{"IOException", // [.\Program] not found
++ "Success",
++ "IOException"}, //SM - no legacy mode [.\Program] - OK
++
++ // [".\Program File\doNot.cmd" arg]
++ new String[]{"Success",
++ "Success",
++ "AccessControlException"}, //SM - [".\Program] - OK,
++ // [.\\Program Files\\doNot.cmd] - Fail
++
++ // [".\Program File\do.cmd" arg]
++ // AccessControlException
++ new String[]{"Success",
++ "Success",
++ "Success"}, //SM - [".\Program] - OK,
++ // [.\\Program Files\\do.cmd] - OK
++
++ // compatibility
++ new String[]{"Success", "Success", "Success"}, //[".\Program.cmd"]
++ new String[]{"Success", "Success", "Success"} //[.\Program.cmd]
++ };
++
++ public static void main(String[] _args) throws Exception {
++ if (!System.getProperty("os.name").startsWith("Windows")) {
++ return;
++ }
++
++ // tear up
++ try {
++ new File(".\\Program Files").mkdirs();
++ for (int i = 0; i < doCmdCopy.length; ++i) {
++ try (BufferedWriter outCmd = new BufferedWriter(
++ new FileWriter(doCmdCopy[i]))) {
++ outCmd.write("@echo %1");
++ }
++ }
++ } catch (IOException e) {
++ throw new Error(e.getMessage());
++ }
++
++ // action
++ for (int k = 0; k < 3; ++k) {
++ switch (k) {
++ case 1:
++ System.setProperty("jdk.lang.Process.allowAmbigousCommands", "");
++ break;
++ case 2:
++ System.setSecurityManager( new SecurityMan() );
++ break;
++ }
++ for (int i = 0; i < TEST_RTE_ARG.length; ++i) {
++ String outRes;
++ try {
++ Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]);
++ exec.waitFor();
++ outRes = "Success";
++ } catch (IOException ioe) {
++ outRes = "IOException: " + ioe.getMessage();
++ } catch (IllegalArgumentException iae) {
++ outRes = "IllegalArgumentException: " + iae.getMessage();
++ } catch (AccessControlException se) {
++ outRes = "AccessControlException: " + se.getMessage();
++ }
++
++ if (!outRes.startsWith(TEST_RTE_GI[i][k])) {
++ throw new Error("Unexpected output! Step" + k + "" + i
++ + " \nArgument: " + TEST_RTE_ARG[i]
++ + "\nExpected: " + TEST_RTE_GI[i][k]
++ + "\n Output: " + outRes);
++ } else {
++ System.out.println("RTE OK:" + TEST_RTE_ARG[i]);
++ }
++ }
++ }
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8012617-arrayindexoutofbounds_linebreakmeasurer.patch b/java/openjdk6/files/icedtea/openjdk/8012617-arrayindexoutofbounds_linebreakmeasurer.patch
new file mode 100644
index 000000000000..2b9d41d8dae5
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8012617-arrayindexoutofbounds_linebreakmeasurer.patch
@@ -0,0 +1,515 @@
+# HG changeset patch
+# User prr
+# Date 1382993769 0
+# Mon Oct 28 20:56:09 2013 +0000
+# Node ID 150e0c3e95ce6869f8e7b42c6d8683817433e124
+# Parent 9cfb9105241489a5fbc3fcfdea15a6aee15b2cfc
+8012617: ArrayIndexOutOfBoundsException with some fonts using LineBreakMeasurer
+Reviewed-by: bae, srl, omajid
+
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/classes/sun/font/ExtendedTextSourceLabel.java
+--- jdk/src/share/classes/sun/font/ExtendedTextSourceLabel.java Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/classes/sun/font/ExtendedTextSourceLabel.java Mon Oct 28 20:56:09 2013 +0000
+@@ -246,6 +246,10 @@
+ float aw = 0f;
+ float ah = cm.ascent + cm.descent;
+
++ if (charinfo == null || charinfo.length == 0) {
++ return new Rectangle2D.Float(al, at, aw, ah);
++ }
++
+ boolean lineIsLTR = (source.getLayoutFlags() & 0x8) == 0;
+ int rn = info.length - numvals;
+ if (lineIsLTR) {
+@@ -349,24 +353,42 @@
+
+ public float getCharX(int index) {
+ validate(index);
+- return getCharinfo()[l2v(index) * numvals + posx];
++ float[] charinfo = getCharinfo();
++ int idx = l2v(index) * numvals + posx;
++ if (charinfo == null || idx >= charinfo.length) {
++ return 0f;
++ } else {
++ return charinfo[idx];
++ }
+ }
+
+ public float getCharY(int index) {
+ validate(index);
+- return getCharinfo()[l2v(index) * numvals + posy];
++ float[] charinfo = getCharinfo();
++ int idx = l2v(index) * numvals + posy;
++ if (charinfo == null || idx >= charinfo.length) {
++ return 0f;
++ } else {
++ return charinfo[idx];
++ }
+ }
+
+ public float getCharAdvance(int index) {
+ validate(index);
+- return getCharinfo()[l2v(index) * numvals + advx];
++ float[] charinfo = getCharinfo();
++ int idx = l2v(index) * numvals + advx;
++ if (charinfo == null || idx >= charinfo.length) {
++ return 0f;
++ } else {
++ return charinfo[idx];
++ }
+ }
+
+ public Rectangle2D handleGetCharVisualBounds(int index) {
+ validate(index);
+ float[] charinfo = getCharinfo();
+ index = l2v(index) * numvals;
+- if ((index+vish) >= charinfo.length) {
++ if (charinfo == null || (index+vish) >= charinfo.length) {
+ return new Rectangle2D.Float();
+ }
+ return new Rectangle2D.Float(
+@@ -462,7 +484,7 @@
+ if (cidx >= charinfo.length) {
+ break; // layout bailed for some reason
+ }
+- float adv = charinfo[l2v(start) * numvals + advx];
++ float adv = charinfo[cidx];
+ width -= adv;
+ }
+
+@@ -511,7 +533,13 @@
+ // }
+ //}
+
+- return getCharinfo()[v * numvals + advx] != 0;
++ int idx = v * numvals + advx;
++ float[] charinfo = getCharinfo();
++ if (charinfo == null || idx >= charinfo.length) {
++ return false;
++ } else {
++ return charinfo[idx] != 0;
++ }
+ }
+
+ private final float[] getCharinfo() {
+@@ -603,6 +631,9 @@
+ */
+
+ int numGlyphs = gv.getNumGlyphs();
++ if (numGlyphs == 0) {
++ return glyphinfo;
++ }
+ int[] indices = gv.getGlyphCharIndices(0, numGlyphs, null);
+
+ boolean DEBUG = false;
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/classes/sun/font/GlyphLayout.java
+--- jdk/src/share/classes/sun/font/GlyphLayout.java Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/classes/sun/font/GlyphLayout.java Mon Oct 28 20:56:09 2013 +0000
+@@ -76,9 +76,12 @@
+ import java.awt.geom.Point2D;
+ import java.util.ArrayList;
+ import java.util.concurrent.ConcurrentHashMap;
++import java.util.logging.Logger;
+
+ import static java.lang.Character.*;
+
++import sun.java2d.SunGraphicsEnvironment;
++
+ public final class GlyphLayout {
+ // data for glyph vector
+ private GVData _gvdata;
+@@ -461,7 +464,12 @@
+ break;
+ }
+ catch (IndexOutOfBoundsException e) {
+- _gvdata.grow();
++ if (_gvdata._count >=0) {
++ _gvdata.grow();
++ }
++ }
++ if (_gvdata._count < 0) {
++ break;
+ }
+ }
+ }
+@@ -470,7 +478,19 @@
+ // _gvdata.adjustPositions(txinfo.invdtx);
+ // }
+
+- StandardGlyphVector gv = _gvdata.createGlyphVector(font, frc, result);
++ // If layout fails (negative glyph count) create an un-laid out GV instead.
++ // ie default positions. This will be a lot better than the alternative of
++ // a complete blank layout.
++ StandardGlyphVector gv;
++ if (_gvdata._count < 0) {
++ gv = new StandardGlyphVector(font, text, offset, count, frc);
++ if (SunGraphicsEnvironment.debugFonts) {
++ Logger.getLogger("sun.java2d").warning("OpenType layout failed on font: " +
++ font);
++ }
++ } else {
++ gv = _gvdata.createGlyphVector(font, frc, result);
++ }
+ // System.err.println("Layout returns: " + gv);
+ return gv;
+ }
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/ContextualSubstSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/ContextualSubstSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/ContextualSubstSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -218,6 +218,9 @@
+
+ LEGlyphID glyph = glyphIterator->getCurrGlyphID();
+ le_int32 coverageIndex = getGlyphCoverage(lookupProcessor->getReference(), glyph, success);
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
+
+ if (coverageIndex >= 0) {
+ le_uint16 srSetCount = SWAPW(subRuleSetCount);
+@@ -267,6 +270,9 @@
+
+ LEGlyphID glyph = glyphIterator->getCurrGlyphID();
+ le_int32 coverageIndex = getGlyphCoverage(lookupProcessor->getReference(), glyph, success);
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
+
+ if (coverageIndex >= 0) {
+ const ClassDefinitionTable *classDefinitionTable =
+@@ -395,6 +401,9 @@
+
+ LEGlyphID glyph = glyphIterator->getCurrGlyphID();
+ le_int32 coverageIndex = getGlyphCoverage(lookupProcessor->getReference(), glyph, success);
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
+
+ if (coverageIndex >= 0) {
+ le_uint16 srSetCount = SWAPW(chainSubRuleSetCount);
+@@ -466,6 +475,9 @@
+
+ LEGlyphID glyph = glyphIterator->getCurrGlyphID();
+ le_int32 coverageIndex = getGlyphCoverage(lookupProcessor->getReference(), glyph, success);
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
+
+ if (coverageIndex >= 0) {
+ const ClassDefinitionTable *backtrackClassDefinitionTable =
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/CursiveAttachmentSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/CursiveAttachmentSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/CursiveAttachmentSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -45,7 +45,7 @@
+ le_int32 coverageIndex = getGlyphCoverage(base, glyphID, success);
+ le_uint16 eeCount = SWAPW(entryExitCount);
+
+- if (coverageIndex < 0 || coverageIndex >= eeCount) {
++ if (coverageIndex < 0 || coverageIndex >= eeCount || LE_FAILURE(success)) {
+ glyphIterator->setCursiveGlyph();
+ return 0;
+ }
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/ExtensionSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/ExtensionSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/ExtensionSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -44,10 +44,10 @@
+ #define READ_LONG(code) (le_uint32)((SWAPW(*(le_uint16*)&code) << 16) + SWAPW(*(((le_uint16*)&code) + 1)))
+
+ // FIXME: should look at the format too... maybe have a sub-class for it?
+-le_uint32 ExtensionSubtable::process(const LookupProcessor *lookupProcessor, le_uint16 lookupType,
++le_uint32 ExtensionSubtable::process(const LEReferenceTo<ExtensionSubtable> &thisRef,
++ const LookupProcessor *lookupProcessor, le_uint16 lookupType,
+ GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const
+ {
+- const LEReferenceTo<ExtensionSubtable> thisRef(lookupProcessor->getReference(), success); // create a reference to this
+
+ if (LE_FAILURE(success)) {
+ return 0;
+@@ -57,7 +57,7 @@
+
+ if (elt != lookupType) {
+ le_uint32 extOffset = READ_LONG(extensionOffset);
+- LEReferenceTo<LookupSubtable> subtable(thisRef, success, extOffset);
++ LEReferenceTo<LookupSubtable> subtable(thisRef, success, extOffset);
+
+ if(LE_SUCCESS(success)) {
+ return lookupProcessor->applySubtable(subtable, elt, glyphIterator, fontInstance, success);
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/ExtensionSubtables.h
+--- jdk/src/share/native/sun/font/layout/ExtensionSubtables.h Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/ExtensionSubtables.h Mon Oct 28 20:56:09 2013 +0000
+@@ -52,7 +52,8 @@
+ le_uint16 extensionLookupType;
+ le_uint32 extensionOffset;
+
+- le_uint32 process(const LookupProcessor *lookupProcessor, le_uint16 lookupType,
++ le_uint32 process(const LEReferenceTo<ExtensionSubtable> &extRef,
++ const LookupProcessor *lookupProcessor, le_uint16 lookupType,
+ GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const;
+ };
+
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/GlyphPosnLookupProc.cpp
+--- jdk/src/share/native/sun/font/layout/GlyphPosnLookupProc.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/GlyphPosnLookupProc.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -168,7 +168,7 @@
+ {
+ LEReferenceTo<ExtensionSubtable> subtable(lookupSubtable, success);
+
+- delta = subtable->process(this, lookupType, glyphIterator, fontInstance, success);
++ delta = subtable->process(subtable, this, lookupType, glyphIterator, fontInstance, success);
+ break;
+ }
+
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/GlyphSubstLookupProc.cpp
+--- jdk/src/share/native/sun/font/layout/GlyphSubstLookupProc.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/GlyphSubstLookupProc.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -139,7 +139,7 @@
+ {
+ const LEReferenceTo<ExtensionSubtable> subtable(lookupSubtable, success);
+
+- delta = subtable->process(this, lookupType, glyphIterator, fontInstance, success);
++ delta = subtable->process(subtable, this, lookupType, glyphIterator, fontInstance, success);
+ break;
+ }
+
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/LigatureSubstSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/LigatureSubstSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/LigatureSubstSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -45,6 +45,10 @@
+ LEGlyphID glyph = glyphIterator->getCurrGlyphID();
+ le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
+
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
++
+ if (coverageIndex >= 0) {
+ Offset ligSetTableOffset = SWAPW(ligSetTableOffsetArray[coverageIndex]);
+ const LigatureSetTable *ligSetTable = (const LigatureSetTable *) ((char *) this + ligSetTableOffset);
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -56,6 +56,10 @@
+ LEGlyphID markGlyph = glyphIterator->getCurrGlyphID();
+ le_int32 markCoverage = getGlyphCoverage(base, (LEGlyphID) markGlyph, success);
+
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
++
+ if (markCoverage < 0) {
+ // markGlyph isn't a covered mark glyph
+ return 0;
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -55,6 +55,10 @@
+ LEGlyphID markGlyph = glyphIterator->getCurrGlyphID();
+ le_int32 markCoverage = getGlyphCoverage(base, (LEGlyphID) markGlyph, success);
+
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
++
+ if (markCoverage < 0) {
+ // markGlyph isn't a covered mark glyph
+ return 0;
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -56,6 +56,10 @@
+ LEGlyphID markGlyph = glyphIterator->getCurrGlyphID();
+ le_int32 markCoverage = getGlyphCoverage(base, (LEGlyphID) markGlyph, success);
+
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
++
+ if (markCoverage < 0) {
+ // markGlyph isn't a covered mark glyph
+ return 0;
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/MultipleSubstSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/MultipleSubstSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/MultipleSubstSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -61,6 +61,10 @@
+ le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
+ le_uint16 seqCount = SWAPW(sequenceCount);
+
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
++
+ if (coverageIndex >= 0 && coverageIndex < seqCount) {
+ Offset sequenceTableOffset = SWAPW(sequenceTableOffsetArray[coverageIndex]);
+ const SequenceTable *sequenceTable = (const SequenceTable *) ((char *) this + sequenceTableOffset);
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/PairPositioningSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/PairPositioningSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/PairPositioningSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -126,6 +126,11 @@
+ {
+ 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()) {
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/SinglePositioningSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/SinglePositioningSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/SinglePositioningSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -70,6 +70,9 @@
+ {
+ LEGlyphID glyph = glyphIterator->getCurrGlyphID();
+ le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
+
+ if (coverageIndex >= 0) {
+ valueRecord.adjustPosition(SWAPW(valueFormat), (const char *) this, *glyphIterator, fontInstance);
+@@ -84,6 +87,9 @@
+ {
+ LEGlyphID glyph = glyphIterator->getCurrGlyphID();
+ le_int16 coverageIndex = (le_int16) getGlyphCoverage(base, glyph, success);
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
+
+ if (coverageIndex >= 0) {
+ valueRecordArray[0].adjustPosition(coverageIndex, SWAPW(valueFormat), (const char *) this, *glyphIterator, fontInstance);
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/SingleSubstitutionSubtables.cpp
+--- jdk/src/share/native/sun/font/layout/SingleSubstitutionSubtables.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/SingleSubstitutionSubtables.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -69,6 +69,9 @@
+ {
+ LEGlyphID glyph = glyphIterator->getCurrGlyphID();
+ le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
+
+ if (coverageIndex >= 0) {
+ TTGlyphID substitute = ((TTGlyphID) LE_GET_GLYPH(glyph)) + SWAPW(deltaGlyphID);
+@@ -87,6 +90,9 @@
+ {
+ LEGlyphID glyph = glyphIterator->getCurrGlyphID();
+ le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
++ if (LE_FAILURE(success)) {
++ return 0;
++ }
+
+ if (coverageIndex >= 0) {
+ TTGlyphID substitute = SWAPW(substituteArray[coverageIndex]);
+diff -r 9cfb91052414 -r 150e0c3e95ce src/share/native/sun/font/layout/SunLayoutEngine.cpp
+--- jdk/src/share/native/sun/font/layout/SunLayoutEngine.cpp Tue Jul 16 21:00:34 2013 +0400
++++ jdk/src/share/native/sun/font/layout/SunLayoutEngine.cpp Mon Oct 28 20:56:09 2013 +0000
+@@ -203,16 +203,19 @@
+ getFloat(env, pt, x, y);
+ jboolean rtl = (typo_flags & TYPO_RTL) != 0;
+ int glyphCount = engine->layoutChars(chars, start - min, limit - start, len, rtl, x, y, success);
+- // fprintf(stderr, "sle nl len %d -> gc: %d\n", len, glyphCount); fflush(stderr);
++ // fprintf(stderr, "sle nl len %d -> gc: %d\n", len, glyphCount); fflush(stderr);
+
+ engine->getGlyphPosition(glyphCount, x, y, success);
+
+- // fprintf(stderr, "layout glyphs: %d x: %g y: %g\n", glyphCount, x, y); fflush(stderr);
+-
+- if (putGV(env, gmask, baseIndex, gvdata, engine, glyphCount)) {
+- // !!! hmmm, could use current value in positions array of GVData...
+- putFloat(env, pt, x, y);
+- }
++ // fprintf(stderr, "layout glyphs: %d x: %g y: %g\n", glyphCount, x, y); fflush(stderr);
++ if (LE_FAILURE(success)) {
++ env->SetIntField(gvdata, gvdCountFID, -1); // flag failure
++ } else {
++ if (putGV(env, gmask, baseIndex, gvdata, engine, glyphCount)) {
++ // !!! hmmm, could use current value in positions array of GVData...
++ putFloat(env, pt, x, y);
++ }
++ }
+
+ if (chars != buffer) {
+ free(chars);
+diff -r 9cfb91052414 -r 150e0c3e95ce test/java/awt/font/LineBreakMeasurer/AllFontsLBM.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/awt/font/LineBreakMeasurer/AllFontsLBM.java Mon Oct 28 20:56:09 2013 +0000
+@@ -0,0 +1,78 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++/*
++ * @test
++ * @bug 8012617
++ * @summary ArrayIndexOutOfBoundsException in LineBreakMeasurer
++ */
++
++import java.awt.*;
++import java.awt.image.*;
++import java.awt.font.*;
++import java.awt.geom.*;
++import java.text.*;
++import java.util.Hashtable;
++
++public class AllFontsLBM {
++
++ public static void main(String[] args) {
++ Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
++ for (int i=0;i<allFonts.length; i++) {
++ try {
++ Font f = allFonts[i].deriveFont(Font.PLAIN, 20);
++
++ if ( f.getFontName().startsWith("HiraKaku") ) {
++ continue;
++ }
++
++ System.out.println("Try : " + f.getFontName());
++ System.out.flush();
++ breakLines(f);
++ } catch (Exception e) {
++ System.out.println(allFonts[i]);
++ }
++ }
++ }
++
++ static void breakLines(Font font) {
++ AttributedString vanGogh = new AttributedString(
++ "Many people believe that Vincent van Gogh painted his best works " +
++ "during the two-year period he spent in Provence. Here is where he " +
++ "painted The Starry Night--which some consider to be his greatest " +
++ "work of all. However, as his artistic brilliance reached new " +
++ "heights in Provence, his physical and mental health plummeted. ",
++ new Hashtable());
++ vanGogh.addAttribute(TextAttribute.FONT, font);
++ BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
++ Graphics2D g2d = bi.createGraphics();
++ AttributedCharacterIterator aci = vanGogh.getIterator();
++ FontRenderContext frc = new FontRenderContext(null, false, false);
++ LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
++ lbm.setPosition(aci.getBeginIndex());
++ while (lbm.getPosition() < aci.getEndIndex()) {
++ lbm.nextLayout(100f);
++ }
++
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8013380-logger_stack_walk_glassfish.patch b/java/openjdk6/files/icedtea/openjdk/8013380-logger_stack_walk_glassfish.patch
new file mode 100644
index 000000000000..3a688e8157cc
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8013380-logger_stack_walk_glassfish.patch
@@ -0,0 +1,941 @@
+# HG changeset patch
+# User andrew
+# Date 1372305047 18000
+# Wed Jun 26 22:50:47 2013 -0500
+# Node ID 8733761ca20bb4e46405e274c514bda0e0616a21
+# Parent a7048970934a1425d5486e6acd0b07558be038c4
+8013380: Removal of stack walk to find resource bundle breaks Glassfish startup
+Summary: Use caller's classloader to load resource as an alternative to thread context classloader and system classloader
+Reviewed-by: mchung, alanb
+
+diff -r a7048970934a -r 8733761ca20b src/share/classes/java/util/logging/LogManager.java
+--- jdk/src/share/classes/java/util/logging/LogManager.java Tue Apr 16 16:34:14 2013 -0400
++++ jdk/src/share/classes/java/util/logging/LogManager.java Wed Jun 26 22:50:47 2013 -0500
+@@ -377,11 +377,11 @@
+ // add a new Logger or return the one that has been added previously
+ // as a LogManager subclass may override the addLogger, getLogger,
+ // readConfiguration, and other methods.
+- Logger demandLogger(String name, String resourceBundleName) {
++ Logger demandLogger(String name, String resourceBundleName, Class<?> caller) {
+ Logger result = getLogger(name);
+ if (result == null) {
+ // only allocate the new logger once
+- Logger newLogger = new Logger(name, resourceBundleName);
++ Logger newLogger = new Logger(name, resourceBundleName, caller);
+ do {
+ if (addLogger(newLogger)) {
+ // We successfully added the new Logger that we
+@@ -465,7 +465,7 @@
+ Logger demandLogger(String name, String resourceBundleName) {
+ // a LogManager subclass may have its own implementation to add and
+ // get a Logger. So delegate to the LogManager to do the work.
+- return manager.demandLogger(name, resourceBundleName);
++ return manager.demandLogger(name, resourceBundleName, null);
+ }
+
+ synchronized Logger findLogger(String name) {
+diff -r a7048970934a -r 8733761ca20b src/share/classes/java/util/logging/Logger.java
+--- jdk/src/share/classes/java/util/logging/Logger.java Tue Apr 16 16:34:14 2013 -0400
++++ jdk/src/share/classes/java/util/logging/Logger.java Wed Jun 26 22:50:47 2013 -0500
+@@ -189,6 +189,7 @@
+ private ArrayList<LogManager.LoggerWeakRef> kids; // WeakReferences to loggers that have us as parent
+ private Level levelObject;
+ private volatile int levelValue; // current effective level value
++ private WeakReference<ClassLoader> callersClassLoaderRef;
+
+ /**
+ * GLOBAL_LOGGER_NAME is a name for the global logger.
+@@ -244,15 +245,31 @@
+ * no corresponding resource can be found.
+ */
+ protected Logger(String name, String resourceBundleName) {
++ this(name, resourceBundleName, null);
++ }
++
++ Logger(String name, String resourceBundleName, Class<?> caller) {
+ this.manager = LogManager.getLogManager();
+- if (resourceBundleName != null) {
+- // Note: we may get a MissingResourceException here.
+- setupResourceInfo(resourceBundleName);
+- }
++ setupResourceInfo(resourceBundleName, caller);
+ this.name = name;
+ levelValue = Level.INFO.intValue();
+ }
+
++ private void setCallersClassLoaderRef(Class<?> caller) {
++ ClassLoader callersClassLoader = ((caller != null)
++ ? caller.getClassLoader()
++ : null);
++ if (callersClassLoader != null) {
++ this.callersClassLoaderRef = new WeakReference(callersClassLoader);
++ }
++ }
++
++ private ClassLoader getCallersClassLoader() {
++ return (callersClassLoaderRef != null)
++ ? callersClassLoaderRef.get()
++ : null;
++ }
++
+ // This constructor is used only to create the global Logger.
+ // It is needed to break a cyclic dependence between the LogManager
+ // and Logger static initializers causing deadlocks.
+@@ -306,7 +323,9 @@
+ return manager.demandSystemLogger(name, resourceBundleName);
+ }
+ }
+- return manager.demandLogger(name, resourceBundleName);
++ return manager.demandLogger(name, resourceBundleName, caller);
++ // ends up calling new Logger(name, resourceBundleName, caller)
++ // iff the logger doesn't exist already
+ }
+
+ /**
+@@ -382,11 +401,24 @@
+ */
+ @CallerSensitive
+ public static synchronized Logger getLogger(String name, String resourceBundleName) {
+- Logger result = demandLogger(name, resourceBundleName, Reflection.getCallerClass());
++ Class<?> callerClass = Reflection.getCallerClass();
++ Logger result = demandLogger(name, resourceBundleName, callerClass);
++
+ if (result.resourceBundleName == null) {
++ // We haven't set a bundle name yet on the Logger, so it's ok to proceed.
++
++ // We have to set the callers ClassLoader here in case demandLogger
++ // above found a previously created Logger. This can happen, for
++ // example, if Logger.getLogger(name) is called and subsequently
++ // Logger.getLogger(name, resourceBundleName) is called. In this case
++ // we won't necessarily have the correct classloader saved away, so
++ // we need to set it here, too.
++
+ // Note: we may get a MissingResourceException here.
+- result.setupResourceInfo(resourceBundleName);
++ result.setupResourceInfo(resourceBundleName, callerClass);
+ } else if (!result.resourceBundleName.equals(resourceBundleName)) {
++ // We already had a bundle name on the Logger and we're trying
++ // to change it here which is not allowed.
+ throw new IllegalArgumentException(result.resourceBundleName +
+ " != " + resourceBundleName);
+ }
+@@ -441,11 +473,13 @@
+ * @return a newly created private Logger
+ * @throws MissingResourceException if the named ResourceBundle cannot be found.
+ */
++ @CallerSensitive
+ public static synchronized Logger getAnonymousLogger(String resourceBundleName) {
+ LogManager manager = LogManager.getLogManager();
+ // cleanup some Loggers that have been GC'ed
+ manager.drainLoggerRefQueueBounded();
+- Logger result = new Logger(null, resourceBundleName);
++ Logger result = new Logger(null, resourceBundleName,
++ Reflection.getCallerClass());
+ result.anonymous = true;
+ Logger root = manager.getLogger("");
+ result.doSetParent(root);
+@@ -461,7 +495,7 @@
+ * @return localization bundle (may be null)
+ */
+ public ResourceBundle getResourceBundle() {
+- return findResourceBundle(getResourceBundleName());
++ return findResourceBundle(getResourceBundleName(), true);
+ }
+
+ /**
+@@ -548,7 +582,7 @@
+ String ebname = getEffectiveResourceBundleName();
+ if (ebname != null && !ebname.equals(SYSTEM_LOGGER_RB_NAME)) {
+ lr.setResourceBundleName(ebname);
+- lr.setResourceBundle(findResourceBundle(ebname));
++ lr.setResourceBundle(findResourceBundle(ebname, true));
+ }
+ log(lr);
+ }
+@@ -765,7 +799,7 @@
+ lr.setLoggerName(name);
+ if (rbname != null) {
+ lr.setResourceBundleName(rbname);
+- lr.setResourceBundle(findResourceBundle(rbname));
++ lr.setResourceBundle(findResourceBundle(rbname, false));
+ }
+ log(lr);
+ }
+@@ -789,7 +823,6 @@
+ * can be null
+ * @param msg The string message (or a key in the message catalog)
+ */
+-
+ public void logrb(Level level, String sourceClass, String sourceMethod,
+ String bundleName, String msg) {
+ if (level.intValue() < levelValue || levelValue == offValue) {
+@@ -1323,9 +1356,18 @@
+ * there is no suitable previous cached value.
+ *
+ * @param name the ResourceBundle to locate
++ * @param userCallersClassLoader if true search using the caller's ClassLoader
+ * @return ResourceBundle specified by name or null if not found
+ */
+- private synchronized ResourceBundle findResourceBundle(String name) {
++ private synchronized ResourceBundle findResourceBundle(String name,
++ boolean useCallersClassLoader) {
++ // For all lookups, we first check the thread context class loader
++ // if it is set. If not, we use the system classloader. If we
++ // still haven't found it we use the callersClassLoaderRef if it
++ // is set and useCallersClassLoader is true. We set
++ // callersClassLoaderRef initially upon creating the logger with a
++ // non-null resource bundle name.
++
+ // Return a null bundle for a null name.
+ if (name == null) {
+ return null;
+@@ -1358,22 +1400,52 @@
+ catalogLocale = currentLocale;
+ return catalog;
+ } catch (MissingResourceException ex) {
++ // We can't find the ResourceBundle in the default
++ // ClassLoader. Drop through.
++ }
++
++ if (useCallersClassLoader) {
++ // Try with the caller's ClassLoader
++ ClassLoader callersClassLoader = getCallersClassLoader();
++
++ if (callersClassLoader == null || callersClassLoader == cl) {
++ return null;
++ }
++
++ try {
++ catalog = ResourceBundle.getBundle(name, currentLocale,
++ callersClassLoader);
++ catalogName = name;
++ catalogLocale = currentLocale;
++ return catalog;
++ } catch (MissingResourceException ex) {
++ return null; // no luck
++ }
++ } else {
+ return null;
+ }
+ }
+
+ // Private utility method to initialize our one entry
+- // resource bundle cache.
++ // resource bundle name cache and the callers ClassLoader
+ // Note: for consistency reasons, we are careful to check
+ // that a suitable ResourceBundle exists before setting the
+- // ResourceBundleName.
+- private synchronized void setupResourceInfo(String name) {
++ // resourceBundleName field.
++ // Synchronized to prevent races in setting the fields.
++ private synchronized void setupResourceInfo(String name,
++ Class<?> callersClass) {
+ if (name == null) {
+ return;
+ }
+- if (findResourceBundle(name) == null) {
++
++ setCallersClassLoaderRef(callersClass);
++ if (findResourceBundle(name, true) == null) {
+ // We've failed to find an expected ResourceBundle.
+- throw new MissingResourceException("Can't find " + name + " bundle", name, "");
++ // unset the caller's ClassLoader since we were unable to find the
++ // the bundle using it
++ this.callersClassLoaderRef = null;
++ throw new MissingResourceException("Can't find " + name + " bundle",
++ name, "");
+ }
+ resourceBundleName = name;
+ }
+diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java
+--- jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Tue Apr 16 16:34:14 2013 -0400
++++ jdk/test/java/util/logging/bundlesearch/IndirectlyLoadABundle.java Wed Jun 26 22:50:47 2013 -0500
+@@ -21,43 +21,28 @@
+ * questions.
+ */
+
+-import java.io.File;
+ import java.lang.reflect.InvocationTargetException;
+ import java.lang.reflect.Method;
++import java.net.MalformedURLException;
+ import java.net.URL;
+ import java.net.URLClassLoader;
++import java.nio.file.Paths;
++import java.util.logging.Logger;
+
+ /**
+ * This class is used to ensure that a resource bundle loadable by a classloader
+- * is on the caller's stack, but not on the classpath or TCCL to ensure that
+- * Logger.getLogger() can't load the bundle via a stack search
++ * is on the caller's stack, but not on the classpath or TCCL. It tests that
++ * Logger.getLogger() can load the bundle via the immediate caller's classloader
+ *
+ * @author Jim Gish
+ */
+ public class IndirectlyLoadABundle {
+
+- private final static String rbName = "StackSearchableResource";
++ private final static String rbName = "CallerSearchableResource";
+
+ public boolean loadAndTest() throws Throwable {
+- // Find out where we are running from so we can setup the URLClassLoader URLs
+- // test.src and test.classes will be set if running in jtreg, but probably
+- // not otherwise
+- String testDir = System.getProperty("test.src", System.getProperty("user.dir"));
+- String testClassesDir = System.getProperty("test.classes",
+- System.getProperty("user.dir"));
+- String sep = System.getProperty("file.separator");
+-
+- URL[] urls = new URL[2];
+-
+- // Allow for both jtreg and standalone cases here
+- urls[0] = new File( testDir + sep + "resources" + sep ).toURI().toURL();
+- urls[1] = new File( testClassesDir + sep ).toURI().toURL();
+-
+- System.out.println("INFO: urls[0] = " + urls[0]);
+- System.out.println("INFO: urls[1] = " + urls[1]);
+-
+ // Make sure we can find it via the URLClassLoader
+- URLClassLoader yetAnotherResourceCL = new URLClassLoader(urls, null);
++ URLClassLoader yetAnotherResourceCL = new URLClassLoader(getURLs(), null);
+ if (!testForValidResourceSetup(yetAnotherResourceCL)) {
+ throw new Exception("Couldn't directly load bundle " + rbName
+ + " as expected. Test config problem");
+@@ -70,23 +55,109 @@
+ + " able to. Test config problem");
+ }
+
+- Class<?> loadItUpClazz = Class.forName("LoadItUp", true, yetAnotherResourceCL);
++ Class<?> loadItUpClazz = Class.forName("LoadItUp1", true,
++ yetAnotherResourceCL);
+ ClassLoader actual = loadItUpClazz.getClassLoader();
+ if (actual != yetAnotherResourceCL) {
+- throw new Exception("LoadItUp was loaded by an unexpected CL: " + actual);
++ throw new Exception("LoadItUp1 was loaded by an unexpected CL: " + actual);
+ }
+ Object loadItUp = loadItUpClazz.newInstance();
+- Method testMethod = loadItUpClazz.getMethod("test", String.class);
++ Method testMethod = loadItUpClazz.getMethod("getLogger", String.class, String.class);
+ try {
+- return (Boolean) testMethod.invoke(loadItUp, rbName);
++ return (Logger)testMethod.invoke(loadItUp, "NestedLogger1", rbName) != null;
+ } catch (InvocationTargetException ex) {
+ throw ex.getTargetException();
+ }
+ }
+
++ public boolean testGetAnonymousLogger() throws Throwable {
++ // Test getAnonymousLogger()
++ URLClassLoader loadItUpCL = new URLClassLoader(getURLs(), null);
++ Class<?> loadItUpClazz = Class.forName("LoadItUp1", true, loadItUpCL);
++ ClassLoader actual = loadItUpClazz.getClassLoader();
++ if (actual != loadItUpCL) {
++ throw new Exception("LoadItUp1 was loaded by an unexpected CL: "
++ + actual);
++ }
++ Object loadItUpAnon = loadItUpClazz.newInstance();
++ Method testAnonMethod = loadItUpClazz.getMethod("getAnonymousLogger",
++ String.class);
++ try {
++ return (Logger)testAnonMethod.invoke(loadItUpAnon, rbName) != null;
++ } catch (InvocationTargetException ex) {
++ throw ex.getTargetException();
++ }
++ }
++
++
++ public boolean testGetLoggerGetLoggerWithBundle() throws Throwable {
++ // test getLogger("NestedLogger2"); followed by
++ // getLogger("NestedLogger2", rbName) to see if the bundle is found
++ //
++ URL[] urls = getURLs();
++ if (getLoggerWithNewCL(urls, "NestedLogger2", null)) {
++ return getLoggerWithNewCL(urls, "NestedLogger2", rbName);
++
++ } else {
++ throw new Exception("TEST FAILED: first call to getLogger() failed "
++ + " in IndirectlyLoadABundle."
++ + "testGetLoggerGetLoggerWithBundle");
++ }
++ }
++
++ private URL[] getURLs() throws MalformedURLException {
++ // Find out where we are running from so we can setup the URLClassLoader URLs
++ // test.src and test.classes will be set if running in jtreg, but probably
++ // not otherwise
++ String testDir = System.getProperty("test.src", System.getProperty("user.dir"));
++ String testClassesDir = System.getProperty("test.classes",
++ System.getProperty("user.dir"));
++ URL[] urls = new URL[2];
++ // Allow for both jtreg and standalone cases here
++ urls[0] = Paths.get(testDir, "resources").toUri().toURL();
++ urls[1] = Paths.get(testClassesDir).toUri().toURL();
++
++ return urls;
++ }
++
++ private boolean getLoggerWithNewCL(URL[] urls, String loggerName,
++ String bundleName) throws Throwable {
++ Logger result = null;;
++ // Test getLogger("foo"); getLogger("foo", "rbName");
++ // First do the getLogger() call with no bundle name
++ URLClassLoader getLoggerCL = new URLClassLoader(urls, null);
++ Class<?> loadItUpClazz1 = Class.forName("LoadItUp1", true, getLoggerCL);
++ ClassLoader actual = loadItUpClazz1.getClassLoader();
++ if (actual != getLoggerCL) {
++ throw new Exception("LoadItUp1 was loaded by an unexpected CL: "
++ + actual);
++ }
++ Object loadItUp1 = loadItUpClazz1.newInstance();
++ if (bundleName != null) {
++ Method getLoggerMethod = loadItUpClazz1.getMethod("getLogger",
++ String.class,
++ String.class);
++ try {
++ result = (Logger) getLoggerMethod.invoke(loadItUp1, loggerName,
++ bundleName);
++ } catch (InvocationTargetException ex) {
++ throw ex.getTargetException();
++ }
++ } else {
++ Method getLoggerMethod = loadItUpClazz1.getMethod("getLogger",
++ String.class);
++ try {
++ result = (Logger) getLoggerMethod.invoke(loadItUp1, loggerName);
++ } catch (InvocationTargetException ex) {
++ throw ex.getTargetException();
++ }
++ }
++ return result != null;
++ }
++
+ private boolean testForValidResourceSetup(ClassLoader cl) {
+- // First make sure the test environment is setup properly and the bundle actually
+- // exists
++ // First make sure the test environment is setup properly and the bundle
++ // actually exists
+ return ResourceBundleSearchTest.isOnClassPath(rbName, cl);
+ }
+ }
+diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/LoadItUp.java
+--- jdk/test/java/util/logging/bundlesearch/LoadItUp.java Tue Apr 16 16:34:14 2013 -0400
++++ jdk/test/java/util/logging/bundlesearch/LoadItUp.java Wed Jun 26 22:50:47 2013 -0500
+@@ -20,43 +20,30 @@
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+-import java.util.MissingResourceException;
+ import java.util.logging.Logger;
+
+ /*
+- * This class is loaded onto the call stack when the test method is called
+- * and then its classloader can be used to find a property bundle in the same
+- * directory as the class. However, Logger is not allowed
++ * This class is loaded onto the call stack when the getLogger methods are
++ * called and then the classes classloader can be used to find a bundle in
++ * the same directory as the class. However, Logger is not allowed
+ * to find the bundle by looking up the stack for this classloader.
+ * We verify that this cannot happen.
+ *
+ * @author Jim Gish
+ */
+-public class LoadItUp {
+-
+- private final static boolean DEBUG = false;
+-
+- public Boolean test(String rbName) throws Exception {
++public class LoadItUp1 {
++ public Logger getAnonymousLogger(String rbName) throws Exception {
+ // we should not be able to find the resource in this directory via
+ // getLogger calls. The only way that would be possible given this setup
+ // is that if Logger.getLogger searched up the call stack
+- return lookupBundle(rbName);
++ return Logger.getAnonymousLogger(rbName);
+ }
+
+- private boolean lookupBundle(String rbName) {
+- // See if Logger.getLogger can find the resource in this directory
+- try {
+- Logger aLogger = Logger.getLogger("NestedLogger", rbName);
+- } catch (MissingResourceException re) {
+- if (DEBUG) {
+- System.out.println(
+- "As expected, LoadItUp.lookupBundle() did not find the bundle "
+- + rbName);
+- }
+- return false;
+- }
+- System.out.println("FAILED: LoadItUp.lookupBundle() found the bundle "
+- + rbName + " using a stack search.");
+- return true;
++ public Logger getLogger(String loggerName) {
++ return Logger.getLogger(loggerName);
++ }
++
++ public Logger getLogger(String loggerName,String bundleName) {
++ return Logger.getLogger(loggerName, bundleName);
+ }
+ }
+diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/LoadItUp2.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/LoadItUp2.java Wed Jun 26 22:50:47 2013 -0500
+@@ -0,0 +1,62 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++import java.util.MissingResourceException;
++import java.util.logging.Logger;
++
++/*
++ * This class is loaded onto the call stack by LoadItUp2Invoker from a separate
++ * classloader. LoadItUp2Invoker was loaded by a class loader that does have
++ * access to the bundle, but the class loader used to load this class does not.
++ * Thus the logging code should not be able to see the resource bundle unless
++ * it has more than a single level stack crawl, which is not allowed.
++ *
++ * @author Jim Gish
++ */
++public class LoadItUp2 {
++
++ private final static boolean DEBUG = false;
++
++ public Boolean test(String rbName) throws Exception {
++ // we should not be able to find the resource in this directory via
++ // getLogger calls. The only way that would be possible given this setup
++ // is that if Logger.getLogger searched up the call stack
++ return lookupBundle(rbName);
++ }
++
++ private boolean lookupBundle(String rbName) {
++ // See if Logger.getLogger can find the resource in this directory
++ try {
++ Logger aLogger = Logger.getLogger("NestedLogger2", rbName);
++ } catch (MissingResourceException re) {
++ if (DEBUG) {
++ System.out.println(
++ "As expected, LoadItUp2.lookupBundle() did not find the bundle "
++ + rbName);
++ }
++ return false;
++ }
++ System.out.println("FAILED: LoadItUp2.lookupBundle() found the bundle "
++ + rbName + " using a stack search.");
++ return true;
++ }
++}
+diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/LoadItUp2Invoker.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/LoadItUp2Invoker.java Wed Jun 26 22:50:47 2013 -0500
+@@ -0,0 +1,60 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++import java.lang.reflect.InvocationTargetException;
++import java.lang.reflect.Method;
++import java.net.URL;
++import java.net.URLClassLoader;
++
++/**
++ * This class is loaded by a class loader that can see the resource. It creates
++ * a new classloader for LoadItUp2 which cannot see the resource. So, 2 levels
++ * up the call chain we have a class/classloader that can see the resource, but
++ * 1 level up the class/classloader cannot.
++ *
++ * @author Jim Gish
++ */
++public class LoadItUp2Invoker {
++ private URLClassLoader cl;
++ private String rbName;
++ private Object loadItUp2;
++ private Method testMethod;
++
++ public void setup(URL[] urls, String rbName) throws
++ ReflectiveOperationException {
++ this.cl = new URLClassLoader(urls, null);
++ this.rbName = rbName;
++ // Using this new classloader, load the actual test class
++ // which is now two levels removed from the original caller
++ Class<?> loadItUp2Clazz = Class.forName("LoadItUp2", true , cl);
++ this.loadItUp2 = loadItUp2Clazz.newInstance();
++ this.testMethod = loadItUp2Clazz.getMethod("test", String.class);
++ }
++
++ public Boolean test() throws Throwable {
++ try {
++ return (Boolean) testMethod.invoke(loadItUp2, rbName);
++ } catch (InvocationTargetException ex) {
++ throw ex.getTargetException();
++ }
++ }
++}
+diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java
+--- jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Tue Apr 16 16:34:14 2013 -0400
++++ jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Wed Jun 26 22:50:47 2013 -0500
+@@ -23,15 +23,15 @@
+
+ /*
+ * @test
+- * @bug 8010127
++ * @bug 8010127 8013380
+ * @summary Remove the stack search for a resource bundle Logger to use
+ * @author Jim Gish
+- * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp
+- * @run main ResourceBundleSearchTest
++ * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp1 LoadItUp2 TwiceIndirectlyLoadABundle LoadItUp2Invoker
++ * @run main/othervm ResourceBundleSearchTest
+ */
+-import java.io.File;
+ import java.net.URL;
+ import java.net.URLClassLoader;
++import java.nio.file.Paths;
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Locale;
+@@ -39,6 +39,12 @@
+ import java.util.ResourceBundle;
+ import java.util.logging.Logger;
+
++/**
++ * This class tests various scenarios of loading resource bundles from
++ * java.util.logging. Since jtreg uses the logging system, it is necessary to
++ * run these tests using othervm mode to ensure no interference from logging
++ * initialization by jtreg
++ */
+ public class ResourceBundleSearchTest {
+
+ private final static boolean DEBUG = false;
+@@ -49,7 +55,7 @@
+
+ private static int numPass = 0;
+ private static int numFail = 0;
+- private static List<String> msgs = new ArrayList<String>();
++ private static List<String> msgs = new ArrayList<>();
+
+ public static void main(String[] args) throws Throwable {
+ ResourceBundleSearchTest test = new ResourceBundleSearchTest();
+@@ -60,47 +66,54 @@
+ // ensure we are using en as the default Locale so we can find the resource
+ Locale.setDefault(Locale.ENGLISH);
+
+- String testClasses = System.getProperty("test.classes");
+- System.out.println( "test.classes = " + testClasses );
+-
+ ClassLoader myClassLoader = ClassLoader.getSystemClassLoader();
+
+ // Find out where we are running from so we can setup the URLClassLoader URL
+ String userDir = System.getProperty("user.dir");
+ String testDir = System.getProperty("test.src", userDir);
+- String sep = System.getProperty("file.separator");
+
+ URL[] urls = new URL[1];
+
+- urls[0] = new File( testDir + sep + "resources" + sep ).toURI().toURL();
++ urls[0] = Paths.get(testDir, "resources").toUri().toURL();
+ URLClassLoader rbClassLoader = new URLClassLoader(urls);
+
+ // Test 1 - can we find a Logger bundle from doing a stack search?
+ // We shouldn't be able to
+- assertFalse(testGetBundleFromStackSearch(), "testGetBundleFromStackSearch");
++ assertFalse(testGetBundleFromStackSearch(), "1-testGetBundleFromStackSearch");
+
+ // Test 2 - can we find a Logger bundle off of the Thread context class
+ // loader? We should be able to.
+- assertTrue(
+- testGetBundleFromTCCL(TCCL_TEST_BUNDLE, rbClassLoader),
+- "testGetBundleFromTCCL");
++ assertTrue(testGetBundleFromTCCL(TCCL_TEST_BUNDLE, rbClassLoader),
++ "2-testGetBundleFromTCCL");
+
+ // Test 3 - Can we find a Logger bundle from the classpath? We should be
+- // able to, but ....
+- // We check to see if the bundle is on the classpath or not so that this
+- // will work standalone. In the case of jtreg/samevm,
+- // the resource bundles are not on the classpath. Running standalone
+- // (or othervm), they are
++ // able to. We'll first check to make sure the setup is correct and
++ // it actually is on the classpath before checking whether logging
++ // can see it there.
+ if (isOnClassPath(PROP_RB_NAME, myClassLoader)) {
+ debug("We should be able to see " + PROP_RB_NAME + " on the classpath");
+ assertTrue(testGetBundleFromSystemClassLoader(PROP_RB_NAME),
+- "testGetBundleFromSystemClassLoader");
++ "3-testGetBundleFromSystemClassLoader");
+ } else {
+- debug("We should not be able to see " + PROP_RB_NAME + " on the classpath");
+- assertFalse(testGetBundleFromSystemClassLoader(PROP_RB_NAME),
+- "testGetBundleFromSystemClassLoader");
++ throw new Exception("TEST SETUP FAILURE: Cannot see " + PROP_RB_NAME
++ + " on the classpath");
+ }
+
++ // Test 4 - we should be able to find a bundle from the caller's
++ // classloader, but only one level up.
++ assertTrue(testGetBundleFromCallersClassLoader(),
++ "4-testGetBundleFromCallersClassLoader");
++
++ // Test 5 - this ensures that getAnonymousLogger(String rbName)
++ // can find the bundle from the caller's classloader
++ assertTrue(testGetAnonymousLogger(), "5-testGetAnonymousLogger");
++
++ // Test 6 - first call getLogger("myLogger").
++ // Then call getLogger("myLogger","bundleName") from a different ClassLoader
++ // Make sure we find the bundle
++ assertTrue(testGetBundleFromSecondCallersClassLoader(),
++ "6-testGetBundleFromSecondCallersClassLoader");
++
+ report();
+ }
+
+@@ -112,7 +125,7 @@
+ System.out.println(msg);
+ }
+ throw new Exception(numFail + " out of " + (numPass + numFail)
+- + " tests failed.");
++ + " tests failed.");
+ }
+ }
+
+@@ -122,7 +135,7 @@
+ } else {
+ numFail++;
+ System.out.println("FAILED: " + testName
+- + " was supposed to return true but did NOT!");
++ + " was supposed to return true but did NOT!");
+ }
+ }
+
+@@ -132,13 +145,20 @@
+ } else {
+ numFail++;
+ System.out.println("FAILED: " + testName
+- + " was supposed to return false but did NOT!");
++ + " was supposed to return false but did NOT!");
+ }
+ }
+
+ public boolean testGetBundleFromStackSearch() throws Throwable {
+ // This should fail. This was the old functionality to search up the
+ // caller's call stack
++ TwiceIndirectlyLoadABundle indirectLoader = new TwiceIndirectlyLoadABundle();
++ return indirectLoader.loadAndTest();
++ }
++
++ public boolean testGetBundleFromCallersClassLoader() throws Throwable {
++ // This should pass. This exercises getting the bundle using the
++ // class loader of the caller (one level up)
+ IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle();
+ return indirectLoader.loadAndTest();
+ }
+@@ -193,14 +213,29 @@
+ bundleName);
+ } catch (MissingResourceException re) {
+ msgs.add("INFO: testGetBundleFromSystemClassLoader() did not find bundle "
+- + bundleName);
++ + bundleName);
+ return false;
+ }
+ msgs.add("INFO: testGetBundleFromSystemClassLoader() found the bundle "
+- + bundleName);
++ + bundleName);
+ return true;
+ }
+
++ private boolean testGetAnonymousLogger() throws Throwable {
++ // This should pass. This exercises getting the bundle using the
++ // class loader of the caller (one level up) when calling
++ // Logger.getAnonymousLogger(String rbName)
++ IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle();
++ return indirectLoader.testGetAnonymousLogger();
++ }
++
++ private boolean testGetBundleFromSecondCallersClassLoader() throws Throwable {
++ // This should pass. This exercises getting the bundle using the
++ // class loader of the caller (one level up)
++ IndirectlyLoadABundle indirectLoader = new IndirectlyLoadABundle();
++ return indirectLoader.testGetLoggerGetLoggerWithBundle();
++ }
++
+ public static class LoggingThread extends Thread {
+
+ boolean foundBundle = false;
+@@ -227,13 +262,13 @@
+ // this should succeed if the bundle is on the system classpath.
+ try {
+ Logger aLogger = Logger.getLogger(ResourceBundleSearchTest.newLoggerName(),
+- bundleName);
+- msg = "INFO: LoggingRunnable() found the bundle " + bundleName
+- + (setTCCL ? " with " : " without ") + "setting the TCCL";
++ bundleName);
++ msg = "INFO: LoggingThread.run() found the bundle " + bundleName
++ + (setTCCL ? " with " : " without ") + "setting the TCCL";
+ foundBundle = true;
+ } catch (MissingResourceException re) {
+- msg = "INFO: LoggingRunnable() did not find the bundle " + bundleName
+- + (setTCCL ? " with " : " without ") + "setting the TCCL";
++ msg = "INFO: LoggingThread.run() did not find the bundle " + bundleName
++ + (setTCCL ? " with " : " without ") + "setting the TCCL";
+ foundBundle = false;
+ }
+ } catch (Throwable e) {
+diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/TwiceIndirectlyLoadABundle.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/TwiceIndirectlyLoadABundle.java Wed Jun 26 22:50:47 2013 -0500
+@@ -0,0 +1,91 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++import java.lang.reflect.InvocationTargetException;
++import java.lang.reflect.Method;
++import java.net.URL;
++import java.net.URLClassLoader;
++import java.nio.file.Paths;
++
++/**
++ * This class constructs a scenario where a bundle is accessible on the call
++ * stack two levels up from the call to getLogger(), but not on the immediate
++ * caller. This tests that getLogger() isn't doing a stack crawl more than one
++ * level up to find a bundle.
++ *
++ * @author Jim Gish
++ */
++public class TwiceIndirectlyLoadABundle {
++
++ private final static String rbName = "StackSearchableResource";
++
++ public boolean loadAndTest() throws Throwable {
++ // Find out where we are running from so we can setup the URLClassLoader URLs
++ // test.src and test.classes will be set if running in jtreg, but probably
++ // not otherwise
++ String testDir = System.getProperty("test.src", System.getProperty("user.dir"));
++ String testClassesDir = System.getProperty("test.classes",
++ System.getProperty("user.dir"));
++ URL[] urls = new URL[2];
++
++ // Allow for both jtreg and standalone cases here
++ // Unlike the 1-level test where we can get the bundle from the caller's
++ // class loader, for this one we don't want to expose the resource directory
++ // to the next class. That way we're invoking the LoadItUp2Invoker class
++ // from this class that does have access to the resources (two levels
++ // up the call stack), but the Invoker itself won't have access to resource
++ urls[0] = Paths.get(testDir,"resources").toUri().toURL();
++ urls[1] = Paths.get(testClassesDir).toUri().toURL();
++
++ // Make sure we can find it via the URLClassLoader
++ URLClassLoader yetAnotherResourceCL = new URLClassLoader(urls, null);
++ Class<?> loadItUp2InvokerClazz = Class.forName("LoadItUp2Invoker", true,
++ yetAnotherResourceCL);
++ ClassLoader actual = loadItUp2InvokerClazz.getClassLoader();
++ if (actual != yetAnotherResourceCL) {
++ throw new Exception("LoadItUp2Invoker was loaded by an unexpected CL: "
++ + actual);
++ }
++ Object loadItUp2Invoker = loadItUp2InvokerClazz.newInstance();
++
++ Method setupMethod = loadItUp2InvokerClazz.getMethod("setup",
++ urls.getClass(), String.class);
++ try {
++ // For the next class loader we create, we want to leave off
++ // the resources. That way loadItUp2Invoker will have access to
++ // them, but the next class won't.
++ URL[] noResourceUrl = new URL[1];
++ noResourceUrl[0] = urls[1]; // from above -- just the test classes
++ setupMethod.invoke(loadItUp2Invoker, noResourceUrl, rbName);
++ } catch (InvocationTargetException ex) {
++ throw ex.getTargetException();
++ }
++
++ Method testMethod = loadItUp2InvokerClazz.getMethod("test");
++ try {
++ return (Boolean) testMethod.invoke(loadItUp2Invoker);
++ } catch (InvocationTargetException ex) {
++ throw ex.getTargetException();
++ }
++ }
++}
+diff -r a7048970934a -r 8733761ca20b test/java/util/logging/bundlesearch/resources/CallerSearchableResource_en.properties
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/util/logging/bundlesearch/resources/CallerSearchableResource_en.properties Wed Jun 26 22:50:47 2013 -0500
+@@ -0,0 +1,25 @@
++#
++# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++#
++# This code is free software; you can redistribute it and/or modify it
++# under the terms of the GNU General Public License version 2 only, as
++# published by the Free Software Foundation.
++#
++# This code is distributed in the hope that it will be useful, but WITHOUT
++# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++# version 2 for more details (a copy is included in the LICENSE file that
++# accompanied this code).
++#
++# You should have received a copy of the GNU General Public License version
++# 2 along with this work; if not, write to the Free Software Foundation,
++# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++#
++# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++# or visit www.oracle.com if you need additional information or have any
++# questions.
++#
++sample1=translation #4 for sample1
++sample2=translation #4 for sample2
++supports-test=ResourceBundleSearchTest
diff --git a/java/openjdk6/files/icedtea/openjdk/8013503-improve_stream_factories.patch b/java/openjdk6/files/icedtea/openjdk/8013503-improve_stream_factories.patch
new file mode 100644
index 000000000000..bc60729ee668
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8013503-improve_stream_factories.patch
@@ -0,0 +1,224 @@
+# HG changeset patch
+# User joehw
+# Date 1381418310 -3600
+# Thu Oct 10 16:18:30 2013 +0100
+# Node ID b5b1d1fa4bb4fcd8bc0602fd4f3523fe24d9f00b
+# Parent 7e2686f3328994b546b7a5d2f7ed5d994a9a724f
+8013503: Improve stream factories
+Reviewed-by: alanb, dfuchs, mullan
+
+diff -r 7e2686f33289 -r b5b1d1fa4bb4 drop_included/jaxp_src/src/javax/xml/stream/FactoryFinder.java
+--- jaxp/drop_included/jaxp_src/src/javax/xml/stream/FactoryFinder.java Fri Oct 04 12:22:34 2013 -0400
++++ jaxp/drop_included/jaxp_src/src/javax/xml/stream/FactoryFinder.java Thu Oct 10 16:18:30 2013 +0100
+@@ -204,13 +204,15 @@
+ * a property name
+ * @param fallbackClassName Implementation class name, if nothing else
+ * is found. Use null to mean no fallback.
++ * @param standardId Indicate whether the factoryId is standard
++ * or user specified.
+ *
+ * Package private so this code can be shared.
+ */
+- static Object find(String factoryId, String fallbackClassName)
++ static Object find(String factoryId, String fallbackClassName, boolean standardId)
+ throws ConfigurationError
+ {
+- return find(factoryId, null, fallbackClassName);
++ return find(factoryId, null, fallbackClassName, standardId);
+ }
+
+ /**
+@@ -227,23 +229,34 @@
+ * @param fallbackClassName Implementation class name, if nothing else
+ * is found. Use null to mean no fallback.
+ *
++ * @param standardId Indicate whether the factoryId is standard
++ * or user specified.
++ *
+ * Package private so this code can be shared.
+ */
+- static Object find(String factoryId, ClassLoader cl, String fallbackClassName)
++ static Object find(String factoryId, ClassLoader cl, String fallbackClassName,
++ boolean standardId)
+ throws ConfigurationError
+ {
+ dPrint("find factoryId =" + factoryId);
+
+ // Use the system property first
+ try {
+- String systemProp = ss.getSystemProperty(factoryId);
++ String systemProp;
++ if (standardId) {
++ systemProp = ss.getSystemProperty(factoryId);
++ } else {
++ systemProp = System.getProperty(factoryId);
++ }
++
+ if (systemProp != null) {
+ dPrint("found system property, value=" + systemProp);
+ return newInstance(systemProp, null, true);
+ }
+ }
+ catch (SecurityException se) {
+- if (debug) se.printStackTrace();
++ throw new ConfigurationError(
++ "Failed to read factoryId '" + factoryId + "'", se);
+ }
+
+ // Try read $java.home/lib/stax.properties followed by
+diff -r 7e2686f33289 -r b5b1d1fa4bb4 drop_included/jaxp_src/src/javax/xml/stream/XMLEventFactory.java
+--- jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLEventFactory.java Fri Oct 04 12:22:34 2013 -0400
++++ jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLEventFactory.java Thu Oct 10 16:18:30 2013 +0100
+@@ -47,6 +47,9 @@
+ * @since 1.6
+ */
+ public abstract class XMLEventFactory {
++
++ static final String JAXPFACTORYID = "javax.xml.stream.XMLEventFactory";
++
+ protected XMLEventFactory(){}
+
+ /**
+@@ -57,8 +60,7 @@
+ throws FactoryConfigurationError
+ {
+ return (XMLEventFactory) FactoryFinder.find(
+- "javax.xml.stream.XMLEventFactory",
+- "com.sun.xml.internal.stream.events.XMLEventFactoryImpl");
++ JAXPFACTORYID, "com.sun.xml.internal.stream.events.XMLEventFactoryImpl", true);
+ }
+
+ /**
+@@ -91,7 +93,7 @@
+ {
+ return (XMLEventFactory) FactoryFinder.find(
+ "javax.xml.stream.XMLEventFactory",
+- "com.sun.xml.internal.stream.events.XMLEventFactoryImpl");
++ "com.sun.xml.internal.stream.events.XMLEventFactoryImpl", true);
+ }
+
+ /**
+@@ -114,7 +116,8 @@
+ throws FactoryConfigurationError {
+ try {
+ //do not fallback if given classloader can't find the class, throw exception
+- return (XMLEventFactory) FactoryFinder.newInstance(factoryId, classLoader, false);
++ return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader,
++ null, factoryId.equals(JAXPFACTORYID) ? true : false);
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new FactoryConfigurationError(e.getException(),
+ e.getMessage());
+@@ -141,7 +144,8 @@
+ throws FactoryConfigurationError {
+ try {
+ //do not fallback if given classloader can't find the class, throw exception
+- return (XMLEventFactory) FactoryFinder.newInstance(factoryId, classLoader, false);
++ return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader,
++ null, factoryId.equals(JAXPFACTORYID) ? true : false);
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new FactoryConfigurationError(e.getException(),
+ e.getMessage());
+diff -r 7e2686f33289 -r b5b1d1fa4bb4 drop_included/jaxp_src/src/javax/xml/stream/XMLInputFactory.java
+--- jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLInputFactory.java Fri Oct 04 12:22:34 2013 -0400
++++ jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLInputFactory.java Thu Oct 10 16:18:30 2013 +0100
+@@ -139,6 +139,7 @@
+ public static final String ALLOCATOR=
+ "javax.xml.stream.allocator";
+
++ static final String JAXPFACTORYID = "javax.xml.stream.XMLInputFactory";
+ static final String DEFAULIMPL = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
+
+ protected XMLInputFactory(){}
+@@ -150,9 +151,7 @@
+ public static XMLInputFactory newInstance()
+ throws FactoryConfigurationError
+ {
+- return (XMLInputFactory) FactoryFinder.find(
+- "javax.xml.stream.XMLInputFactory",
+- DEFAULIMPL);
++ return (XMLInputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true);
+ }
+
+ /**
+@@ -183,9 +182,7 @@
+ public static XMLInputFactory newFactory()
+ throws FactoryConfigurationError
+ {
+- return (XMLInputFactory) FactoryFinder.find(
+- "javax.xml.stream.XMLInputFactory",
+- DEFAULIMPL);
++ return (XMLInputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true);
+ }
+
+ /**
+@@ -208,7 +205,8 @@
+ throws FactoryConfigurationError {
+ try {
+ //do not fallback if given classloader can't find the class, throw exception
+- return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null);
++ return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader,
++ null, factoryId.equals(JAXPFACTORYID) ? true : false);
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new FactoryConfigurationError(e.getException(),
+ e.getMessage());
+@@ -235,7 +233,8 @@
+ throws FactoryConfigurationError {
+ try {
+ //do not fallback if given classloader can't find the class, throw exception
+- return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null);
++ return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader,
++ null, factoryId.equals(JAXPFACTORYID) ? true : false);
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new FactoryConfigurationError(e.getException(),
+ e.getMessage());
+diff -r 7e2686f33289 -r b5b1d1fa4bb4 drop_included/jaxp_src/src/javax/xml/stream/XMLOutputFactory.java
+--- jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLOutputFactory.java Fri Oct 04 12:22:34 2013 -0400
++++ jaxp/drop_included/jaxp_src/src/javax/xml/stream/XMLOutputFactory.java Thu Oct 10 16:18:30 2013 +0100
+@@ -115,6 +115,7 @@
+ public static final String IS_REPAIRING_NAMESPACES=
+ "javax.xml.stream.isRepairingNamespaces";
+
++ static final String JAXPFACTORYID = "javax.xml.stream.XMLOutputFactory";
+ static final String DEFAULIMPL = "com.sun.xml.internal.stream.XMLOutputFactoryImpl";
+
+ protected XMLOutputFactory(){}
+@@ -126,8 +127,7 @@
+ public static XMLOutputFactory newInstance()
+ throws FactoryConfigurationError
+ {
+- return (XMLOutputFactory) FactoryFinder.find("javax.xml.stream.XMLOutputFactory",
+- DEFAULIMPL);
++ return (XMLOutputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true);
+ }
+
+ /**
+@@ -158,8 +158,7 @@
+ public static XMLOutputFactory newFactory()
+ throws FactoryConfigurationError
+ {
+- return (XMLOutputFactory) FactoryFinder.find("javax.xml.stream.XMLOutputFactory",
+- DEFAULIMPL);
++ return (XMLOutputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true);
+ }
+
+ /**
+@@ -181,7 +180,8 @@
+ throws FactoryConfigurationError {
+ try {
+ //do not fallback if given classloader can't find the class, throw exception
+- return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null);
++ return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader,
++ null, factoryId.equals(JAXPFACTORYID) ? true : false);
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new FactoryConfigurationError(e.getException(),
+ e.getMessage());
+@@ -210,7 +210,8 @@
+ throws FactoryConfigurationError {
+ try {
+ //do not fallback if given classloader can't find the class, throw exception
+- return (XMLOutputFactory) FactoryFinder.find(factoryId, classLoader, null);
++ return (XMLOutputFactory) FactoryFinder.find(factoryId, classLoader,
++ null, factoryId.equals(JAXPFACTORYID) ? true : false);
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new FactoryConfigurationError(e.getException(),
+ e.getMessage());
diff --git a/java/openjdk6/files/icedtea/openjdk/8013506-better_pack200.patch b/java/openjdk6/files/icedtea/openjdk/8013506-better_pack200.patch
new file mode 100644
index 000000000000..b3696fc25fed
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8013506-better_pack200.patch
@@ -0,0 +1,39 @@
+# HG changeset patch
+# User ksrini
+# Date 1381851019 -3600
+# Tue Oct 15 16:30:19 2013 +0100
+# Node ID 8fb384d684f5b9bc76970bdc7e5603b9cd9944b8
+# Parent 337232ddaec36c6d9843ff35906e6160446844eb
+8013506: Better Pack200 data handling
+Reviewed-by: jrose, kizune, mschoene
+
+diff -r 337232ddaec3 -r 8fb384d684f5 src/share/native/com/sun/java/util/jar/pack/zip.cpp
+--- jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp Fri May 31 20:43:32 2013 +0400
++++ jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp Tue Oct 15 16:30:19 2013 +0100
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2001, 2005, 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
+@@ -339,6 +339,10 @@
+ time_t t = modtime;
+ struct tm sbuf;
+ struct tm* s = gmtime_r(&t, &sbuf);
++ if (s == NULL) {
++ fprintf(u->errstrm, "Error: gmtime failure, invalid input archive\n");
++ exit(2);
++ }
+ modtime_cache = modtime;
+ dostime_cache = dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday,
+ s->tm_hour, s->tm_min, s->tm_sec);
+@@ -383,7 +387,7 @@
+ }
+
+ deflated.empty();
+- zs.next_out = (uchar*) deflated.grow(len + (len/2));
++ zs.next_out = (uchar*) deflated.grow(add_size(len, (len/2)));
+ zs.avail_out = deflated.size();
+
+ zs.next_in = (uchar*)head.ptr;
diff --git a/java/openjdk6/files/icedtea/openjdk/8013510-augment_image_writing.patch b/java/openjdk6/files/icedtea/openjdk/8013510-augment_image_writing.patch
new file mode 100644
index 000000000000..8c4946051687
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8013510-augment_image_writing.patch
@@ -0,0 +1,57 @@
+# HG changeset patch
+# User jchen
+# Date 1368123798 25200
+# Thu May 09 11:23:18 2013 -0700
+# Node ID c428e65fa8fd127058ea33ef728391887ea108e6
+# Parent 8fb384d684f5b9bc76970bdc7e5603b9cd9944b8
+8013510: Augment image writing code
+Reviewed-by: bae, prr
+
+diff -r 8fb384d684f5 -r c428e65fa8fd src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
+--- jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Tue Oct 15 16:30:19 2013 +0100
++++ jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Thu May 09 11:23:18 2013 -0700
+@@ -1178,6 +1178,11 @@
+ target = imRas;
+ }
+ int [] bandSizes = target.getSampleModel().getSampleSize();
++ for (int i = 0; i < bandSizes.length; i++) {
++ if (bandSizes[i] <= 0 || bandSizes[i] > 8) {
++ throw new IIOException("Illegal band size: should be 0 < size <= 8");
++ }
++ }
+
+ /*
+ * If the process is sequential, and we have restart markers,
+diff -r 8fb384d684f5 -r c428e65fa8fd src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
+--- jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java Tue Oct 15 16:30:19 2013 +0100
++++ jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java Thu May 09 11:23:18 2013 -0700
+@@ -490,8 +490,8 @@
+ // handle <= 8-bit samples. We now check the band sizes and throw
+ // an exception for images, such as USHORT_GRAY, with > 8 bits
+ // per sample.
+- if (bandSizes[i] > 8) {
+- throw new IIOException("Sample size must be <= 8");
++ if (bandSizes[i] <= 0 || bandSizes[i] > 8) {
++ throw new IIOException("Illegal band size: should be 0 < size <= 8");
+ }
+ // 4450894 part 2: We expand IndexColorModel images to full 24-
+ // or 32-bit in grabPixels() for each scanline. For indexed
+diff -r 8fb384d684f5 -r c428e65fa8fd src/share/native/sun/awt/image/jpeg/imageioJPEG.c
+--- jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Tue Oct 15 16:30:19 2013 +0100
++++ jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Thu May 09 11:23:18 2013 -0700
+@@ -2684,6 +2684,15 @@
+ bandSize = (*env)->GetIntArrayElements(env, bandSizes, NULL);
+
+ for (i = 0; i < numBands; i++) {
++ if (bandSize[i] <= 0 || bandSize[i] > JPEG_BAND_SIZE) {
++ (*env)->ReleaseIntArrayElements(env, bandSizes,
++ bandSize, JNI_ABORT);
++ JNU_ThrowByName(env, "javax/imageio/IIOException", "Invalid Image");
++ return JNI_FALSE;;
++ }
++ }
++
++ for (i = 0; i < numBands; i++) {
+ if (bandSize[i] != JPEG_BAND_SIZE) {
+ mustScale = TRUE;
+ break;
diff --git a/java/openjdk6/files/icedtea/openjdk/8013514-improve_cmap_stability.patch b/java/openjdk6/files/icedtea/openjdk/8013514-improve_cmap_stability.patch
new file mode 100644
index 000000000000..606d87fc139b
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8013514-improve_cmap_stability.patch
@@ -0,0 +1,51 @@
+# HG changeset patch
+# User vadim
+# Date 1381851333 -3600
+# Tue Oct 15 16:35:33 2013 +0100
+# Node ID a28b8ce4d90e7d7bc1fab599298831e0d62e171e
+# Parent c428e65fa8fd127058ea33ef728391887ea108e6
+8013514: Improve stability of cmap class
+Reviewed-by: mschoene, prr, bae
+
+diff -r c428e65fa8fd -r a28b8ce4d90e src/share/classes/sun/font/FileFont.java
+--- jdk/src/share/classes/sun/font/FileFont.java Thu May 09 11:23:18 2013 -0700
++++ jdk/src/share/classes/sun/font/FileFont.java Tue Oct 15 16:35:33 2013 +0100
+@@ -174,7 +174,9 @@
+ }
+ }
+ }
+- scaler.dispose();
++ if (scaler != null) {
++ scaler.dispose();
++ }
+ scaler = FontManager.getNullScaler();
+ }
+
+diff -r c428e65fa8fd -r a28b8ce4d90e src/share/classes/sun/font/StandardGlyphVector.java
+--- jdk/src/share/classes/sun/font/StandardGlyphVector.java Thu May 09 11:23:18 2013 -0700
++++ jdk/src/share/classes/sun/font/StandardGlyphVector.java Tue Oct 15 16:35:33 2013 +0100
+@@ -1733,8 +1733,9 @@
+ tx,
+ sgv.font.getStyle(),
+ aa, fm);
+-
+- FontStrike strike = sgv.font2D.getStrike(desc); // !!! getStrike(desc, false)
++ // Get the strike via the handle. Shouldn't matter
++ // if we've invalidated the font but its an extra precaution.
++ FontStrike strike = sgv.font2D.handle.font2D.getStrike(desc); // !!! getStrike(desc, false)
+
+ return new GlyphStrike(sgv, strike, dx, dy);
+ }
+diff -r c428e65fa8fd -r a28b8ce4d90e src/share/classes/sun/font/TrueTypeFont.java
+--- jdk/src/share/classes/sun/font/TrueTypeFont.java Thu May 09 11:23:18 2013 -0700
++++ jdk/src/share/classes/sun/font/TrueTypeFont.java Tue Oct 15 16:35:33 2013 +0100
+@@ -559,6 +559,9 @@
+ if (head_Table != null && head_Table.capacity() >= 18) {
+ ShortBuffer sb = head_Table.asShortBuffer();
+ upem = sb.get(9) & 0xffff;
++ if (upem < 16 || upem > 16384) {
++ upem = 2048;
++ }
+ }
+ setStrikethroughMetrics(os2_Table, upem);
+
diff --git a/java/openjdk6/files/icedtea/openjdk/8013739-better_ldap_resource_management.patch b/java/openjdk6/files/icedtea/openjdk/8013739-better_ldap_resource_management.patch
new file mode 100644
index 000000000000..ce2e96356cd2
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8013739-better_ldap_resource_management.patch
@@ -0,0 +1,148 @@
+# HG changeset patch
+# User weijun
+# Date 1382990980 0
+# Mon Oct 28 20:09:40 2013 +0000
+# Node ID 42fd9f22ae5e9aea017af28a2b5ff7a498753e15
+# Parent 2adb9f71f6c0723acf40877f059d276557b71034
+8013739: Better LDAP resource management
+Reviewed-by: ahgross, mchung, xuelei
+
+diff -r 2adb9f71f6c0 -r 42fd9f22ae5e src/share/classes/com/sun/jndi/ldap/VersionHelper12.java
+--- jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper12.java Mon Jul 22 14:06:39 2013 -0700
++++ jdk/src/share/classes/com/sun/jndi/ldap/VersionHelper12.java Mon Oct 28 20:09:40 2013 +0000
+@@ -25,11 +25,12 @@
+
+ package com.sun.jndi.ldap;
+
+-import java.net.URL;
+ import java.net.URLClassLoader;
+ import java.net.MalformedURLException;
++import java.security.AccessControlContext;
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
++import sun.misc.SharedSecrets;
+
+ final class VersionHelper12 extends VersionHelper {
+
+@@ -82,12 +83,16 @@
+ }
+
+ Thread createThread(final Runnable r) {
+- return (Thread) AccessController.doPrivileged(
+- new PrivilegedAction() {
+- public Object run() {
+- return new Thread(r);
++ final AccessControlContext acc = AccessController.getContext();
++ // 4290486: doPrivileged is needed to create a thread in
++ // an environment that restricts "modifyThreadGroup".
++ return AccessController.doPrivileged(
++ new PrivilegedAction<Thread>() {
++ public Thread run() {
++ return SharedSecrets.getJavaLangAccess()
++ .newThreadWithAcc(r, acc);
++ }
+ }
+- }
+ );
+ }
+ }
+diff -r 2adb9f71f6c0 -r 42fd9f22ae5e src/share/classes/java/lang/System.java
+--- jdk/src/share/classes/java/lang/System.java Mon Jul 22 14:06:39 2013 -0700
++++ jdk/src/share/classes/java/lang/System.java Mon Oct 28 20:09:40 2013 +0000
+@@ -25,6 +25,7 @@
+ package java.lang;
+
+ import java.io.*;
++import java.security.AccessControlContext;
+ import java.util.Properties;
+ import java.util.PropertyPermission;
+ import java.util.StringTokenizer;
+@@ -1158,6 +1159,9 @@
+ public void blockedOn(Thread t, Interruptible b) {
+ t.blockedOn(b);
+ }
++ public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) {
++ return new Thread(target, acc);
++ }
+ });
+ }
+ }
+diff -r 2adb9f71f6c0 -r 42fd9f22ae5e src/share/classes/java/lang/Thread.java
+--- jdk/src/share/classes/java/lang/Thread.java Mon Jul 22 14:06:39 2013 -0700
++++ jdk/src/share/classes/java/lang/Thread.java Mon Oct 28 20:09:40 2013 +0000
+@@ -322,6 +322,15 @@
+ }
+
+ /**
++ * Initializes a Thread with the current AccessControlContext.
++ * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext)
++ */
++ private void init(ThreadGroup g, Runnable target, String name,
++ long stackSize) {
++ init(g, target, name, stackSize, null);
++ }
++
++ /**
+ * Initializes a Thread.
+ *
+ * @param g the Thread group
+@@ -329,9 +338,11 @@
+ * @param name the name of the new Thread
+ * @param stackSize the desired stack size for the new thread, or
+ * zero to indicate that this parameter is to be ignored.
++ * @param acc the AccessControlContext to inherit, or
++ * AccessController.getContext() if null
+ */
+ private void init(ThreadGroup g, Runnable target, String name,
+- long stackSize) {
++ long stackSize, AccessControlContext acc) {
+ Thread parent = currentThread();
+ SecurityManager security = System.getSecurityManager();
+ if (g == null) {
+@@ -374,7 +385,8 @@
+ this.contextClassLoader = parent.getContextClassLoader();
+ else
+ this.contextClassLoader = parent.contextClassLoader;
+- this.inheritedAccessControlContext = AccessController.getContext();
++ this.inheritedAccessControlContext =
++ acc != null ? acc : AccessController.getContext();
+ this.target = target;
+ setPriority(priority);
+ if (parent.inheritableThreadLocals != null)
+@@ -427,6 +439,14 @@
+ }
+
+ /**
++ * Creates a new Thread that inherits the given AccessControlContext.
++ * This is not a public constructor.
++ */
++ Thread(Runnable target, AccessControlContext acc) {
++ init(null, target, "Thread-" + nextThreadNum(), 0, acc);
++ }
++
++ /**
+ * Allocates a new <code>Thread</code> object. This constructor has
+ * the same effect as <code>Thread(null, null,</code>
+ * <i>gname</i><code>)</code>, where <b><i>gname</i></b> is
+diff -r 2adb9f71f6c0 -r 42fd9f22ae5e src/share/classes/sun/misc/JavaLangAccess.java
+--- jdk/src/share/classes/sun/misc/JavaLangAccess.java Mon Jul 22 14:06:39 2013 -0700
++++ jdk/src/share/classes/sun/misc/JavaLangAccess.java Mon Oct 28 20:09:40 2013 +0000
+@@ -25,6 +25,7 @@
+
+ package sun.misc;
+
++import java.security.AccessControlContext;
+ import sun.reflect.ConstantPool;
+ import sun.reflect.annotation.AnnotationType;
+ import sun.nio.ch.Interruptible;
+@@ -54,4 +55,10 @@
+
+ /** Set thread's blocker field. */
+ void blockedOn(Thread t, Interruptible b);
++
++ /**
++ * Returns a new Thread with the given Runnable and an
++ * inherited AccessControlContext.
++ */
++ Thread newThreadWithAcc(Runnable target, AccessControlContext acc);
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8013744-better_tabling.patch b/java/openjdk6/files/icedtea/openjdk/8013744-better_tabling.patch
new file mode 100644
index 000000000000..ca81f04485fa
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8013744-better_tabling.patch
@@ -0,0 +1,196 @@
+# HG changeset patch
+# User alexsch
+# Date 1381852031 -3600
+# Tue Oct 15 16:47:11 2013 +0100
+# Node ID d10e47deb098d4af5d58a8bfe92dc8033e5ef6f7
+# Parent a28b8ce4d90e7d7bc1fab599298831e0d62e171e
+8013744: Better tabling for AWT
+Reviewed-by: art, malenkov, skoivu
+
+diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/javax/swing/JTable.java
+--- jdk/src/share/classes/javax/swing/JTable.java Tue Oct 15 16:35:33 2013 +0100
++++ jdk/src/share/classes/javax/swing/JTable.java Tue Oct 15 16:47:11 2013 +0100
+@@ -52,6 +52,7 @@
+
+ import javax.print.attribute.*;
+ import javax.print.PrintService;
++import sun.reflect.misc.ReflectUtil;
+
+ import sun.swing.SwingUtilities2;
+ import sun.swing.SwingUtilities2.Section;
+@@ -5461,14 +5462,15 @@
+ // they have the option to replace the value with
+ // null or use escape to restore the original.
+ // For Strings, return "" for backward compatibility.
+- if ("".equals(s)) {
+- if (constructor.getDeclaringClass() == String.class) {
+- value = s;
+- }
+- super.stopCellEditing();
+- }
+-
+ try {
++ if ("".equals(s)) {
++ if (constructor.getDeclaringClass() == String.class) {
++ value = s;
++ }
++ super.stopCellEditing();
++ }
++
++ SwingUtilities2.checkAccess(constructor.getModifiers());
+ value = constructor.newInstance(new Object[]{s});
+ }
+ catch (Exception e) {
+@@ -5492,6 +5494,8 @@
+ if (type == Object.class) {
+ type = String.class;
+ }
++ ReflectUtil.checkPackageAccess(type);
++ SwingUtilities2.checkAccess(type.getModifiers());
+ constructor = type.getConstructor(argTypes);
+ }
+ catch (Exception e) {
+diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/javax/swing/UIDefaults.java
+--- jdk/src/share/classes/javax/swing/UIDefaults.java Tue Oct 15 16:35:33 2013 +0100
++++ jdk/src/share/classes/javax/swing/UIDefaults.java Tue Oct 15 16:47:11 2013 +0100
+@@ -53,6 +53,7 @@
+
+ import sun.reflect.misc.MethodUtil;
+ import sun.reflect.misc.ReflectUtil;
++import sun.swing.SwingUtilities2;
+ import sun.util.CoreResourceBundleControl;
+
+ /**
+@@ -1102,7 +1103,7 @@
+ }
+ ReflectUtil.checkPackageAccess(className);
+ c = Class.forName(className, true, (ClassLoader)cl);
+- checkAccess(c.getModifiers());
++ SwingUtilities2.checkAccess(c.getModifiers());
+ if (methodName != null) {
+ Class[] types = getClassArray(args);
+ Method m = c.getMethod(methodName, types);
+@@ -1110,7 +1111,7 @@
+ } else {
+ Class[] types = getClassArray(args);
+ Constructor constructor = c.getConstructor(types);
+- checkAccess(constructor.getModifiers());
++ SwingUtilities2.checkAccess(constructor.getModifiers());
+ return constructor.newInstance(args);
+ }
+ } catch(Exception e) {
+@@ -1125,13 +1126,6 @@
+ }, acc);
+ }
+
+- private void checkAccess(int modifiers) {
+- if(System.getSecurityManager() != null &&
+- !Modifier.isPublic(modifiers)) {
+- throw new SecurityException("Resource is not accessible");
+- }
+- }
+-
+ /*
+ * Coerce the array of class types provided into one which
+ * looks the way the Reflection APIs expect. This is done
+diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/javax/swing/text/DefaultFormatter.java
+--- jdk/src/share/classes/javax/swing/text/DefaultFormatter.java Tue Oct 15 16:35:33 2013 +0100
++++ jdk/src/share/classes/javax/swing/text/DefaultFormatter.java Tue Oct 15 16:47:11 2013 +0100
+@@ -24,7 +24,8 @@
+ */
+ package javax.swing.text;
+
+-import sun.reflect.misc.ConstructorUtil;
++import sun.reflect.misc.ReflectUtil;
++import sun.swing.SwingUtilities2;
+
+ import java.io.Serializable;
+ import java.lang.reflect.*;
+@@ -247,7 +248,9 @@
+ Constructor cons;
+
+ try {
+- cons = ConstructorUtil.getConstructor(vc, new Class[]{String.class});
++ ReflectUtil.checkPackageAccess(vc);
++ SwingUtilities2.checkAccess(vc.getModifiers());
++ cons = vc.getConstructor(new Class[]{String.class});
+
+ } catch (NoSuchMethodException nsme) {
+ cons = null;
+@@ -255,6 +258,7 @@
+
+ if (cons != null) {
+ try {
++ SwingUtilities2.checkAccess(cons.getModifiers());
+ return cons.newInstance(new Object[] { string });
+ } catch (Throwable ex) {
+ throw new ParseException("Error creating instance", 0);
+diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/javax/swing/text/NumberFormatter.java
+--- jdk/src/share/classes/javax/swing/text/NumberFormatter.java Tue Oct 15 16:35:33 2013 +0100
++++ jdk/src/share/classes/javax/swing/text/NumberFormatter.java Tue Oct 15 16:47:11 2013 +0100
+@@ -28,6 +28,8 @@
+ import java.text.*;
+ import java.util.*;
+ import javax.swing.text.*;
++import sun.reflect.misc.ReflectUtil;
++import sun.swing.SwingUtilities2;
+
+ /**
+ * <code>NumberFormatter</code> subclasses <code>InternationalFormatter</code>
+@@ -466,10 +468,12 @@
+ valueClass = value.getClass();
+ }
+ try {
++ ReflectUtil.checkPackageAccess(valueClass);
++ SwingUtilities2.checkAccess(valueClass.getModifiers());
+ Constructor cons = valueClass.getConstructor(
+ new Class[] { String.class });
+-
+ if (cons != null) {
++ SwingUtilities2.checkAccess(cons.getModifiers());
+ return cons.newInstance(new Object[]{string});
+ }
+ } catch (Throwable ex) { }
+diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/sun/swing/SwingLazyValue.java
+--- jdk/src/share/classes/sun/swing/SwingLazyValue.java Tue Oct 15 16:35:33 2013 +0100
++++ jdk/src/share/classes/sun/swing/SwingLazyValue.java Tue Oct 15 16:47:11 2013 +0100
+@@ -30,6 +30,7 @@
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
+ import javax.swing.UIDefaults;
++import sun.reflect.misc.ReflectUtil;
+
+ /**
+ * SwingLazyValue is a copy of ProxyLazyValue that does not snapshot the
+@@ -64,7 +65,7 @@
+ public Object createValue(final UIDefaults table) {
+ try {
+ Class c;
+- Object cl;
++ ReflectUtil.checkPackageAccess(className);
+ c = Class.forName(className, true, null);
+ if (methodName != null) {
+ Class[] types = getClassArray(args);
+diff -r a28b8ce4d90e -r d10e47deb098 src/share/classes/sun/swing/SwingUtilities2.java
+--- jdk/src/share/classes/sun/swing/SwingUtilities2.java Tue Oct 15 16:35:33 2013 +0100
++++ jdk/src/share/classes/sun/swing/SwingUtilities2.java Tue Oct 15 16:47:11 2013 +0100
+@@ -1319,6 +1319,19 @@
+ }
+
+ /**
++ * Utility method that throws SecurityException if SecurityManager is set
++ * and modifiers are not public
++ *
++ * @param modifiers a set of modifiers
++ */
++ public static void checkAccess(int modifiers) {
++ if (System.getSecurityManager() != null
++ && !Modifier.isPublic(modifiers)) {
++ throw new SecurityException("Resource is not accessible");
++ }
++ }
++
++ /**
+ * Returns true if EventQueue.getCurrentEvent() has the permissions to
+ * access the system clipboard and if it is allowed gesture (if
+ * checkGesture true)
diff --git a/java/openjdk6/files/icedtea/openjdk/8013827-createtempfile_hang.patch b/java/openjdk6/files/icedtea/openjdk/8013827-createtempfile_hang.patch
new file mode 100644
index 000000000000..89db40974250
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8013827-createtempfile_hang.patch
@@ -0,0 +1,176 @@
+# HG changeset patch
+# User dxu
+# Date 1383018580 0
+# Tue Oct 29 03:49:40 2013 +0000
+# Node ID 8459b68eb028734b2153266176538e1eddbb87be
+# Parent 8ad2eb12bf42f2564fdf80a7236e4046046a4f4e
+8013827: File.createTempFile hangs with temp file starting with 'com1.4'
+8011950: java.io.File.createTempFile enters infinite loop when passed invalid data
+Reviewed-by: alanb
+
+diff -r 8ad2eb12bf42 -r 8459b68eb028 src/share/classes/java/io/File.java
+--- jdk/src/share/classes/java/io/File.java Tue Oct 29 03:05:18 2013 +0000
++++ jdk/src/share/classes/java/io/File.java Tue Oct 29 03:49:40 2013 +0000
+@@ -1801,7 +1801,11 @@
+ } else {
+ n = Math.abs(n);
+ }
+- return new File(dir, prefix + Long.toString(n) + suffix);
++ String name = prefix + Long.toString(n) + suffix;
++ File f = new File(dir, name);
++ if (!name.equals(f.getName()))
++ throw new IOException("Unable to create temporary file");
++ return f;
+ }
+
+ private static boolean checkAndCreate(String filename, SecurityManager sm,
+diff -r 8ad2eb12bf42 -r 8459b68eb028 src/windows/native/java/io/WinNTFileSystem_md.c
+--- jdk/src/windows/native/java/io/WinNTFileSystem_md.c Tue Oct 29 03:05:18 2013 +0000
++++ jdk/src/windows/native/java/io/WinNTFileSystem_md.c Tue Oct 29 03:49:40 2013 +0000
+@@ -356,6 +356,10 @@
+ WCHAR *pathbuf = pathToNTPath(env, path, JNI_FALSE);
+ if (pathbuf == NULL)
+ return JNI_FALSE;
++ if (isReservedDeviceNameW(pathbuf)) {
++ free(pathbuf);
++ return JNI_FALSE;
++ }
+ h = CreateFileW(
+ pathbuf, /* Wide char path name */
+ GENERIC_READ | GENERIC_WRITE, /* Read and write permission */
+diff -r 8ad2eb12bf42 -r 8459b68eb028 test/java/io/File/CreateNewFile.java
+--- jdk/test/java/io/File/CreateNewFile.java Tue Oct 29 03:05:18 2013 +0000
++++ jdk/test/java/io/File/CreateNewFile.java Tue Oct 29 03:49:40 2013 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2001, 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
+@@ -22,7 +22,7 @@
+ */
+
+ /* @test
+- @bug 4130498 4391178
++ @bug 4130498 4391178 6198547
+ @summary Basic test for createNewFile method
+ */
+
+@@ -51,5 +51,20 @@
+ } catch (IOException e) {
+ // Exception expected
+ }
++
++ testCreateExistingDir();
++ }
++
++ // Test JDK-6198547
++ private static void testCreateExistingDir() throws IOException {
++ File tmpFile = new File("hugo");
++ if (tmpFile.exists() && !tmpFile.delete())
++ throw new RuntimeException("Cannot delete " + tmpFile);
++ if (!tmpFile.mkdir())
++ throw new RuntimeException("Cannot create dir " + tmpFile);
++ if (!tmpFile.exists())
++ throw new RuntimeException("Cannot see created dir " + tmpFile);
++ if (tmpFile.createNewFile())
++ throw new RuntimeException("Should fail to create file " + tmpFile);
+ }
+ }
+diff -r 8ad2eb12bf42 -r 8459b68eb028 test/java/io/File/NulFile.java
+--- jdk/test/java/io/File/NulFile.java Tue Oct 29 03:05:18 2013 +0000
++++ jdk/test/java/io/File/NulFile.java Tue Oct 29 03:49:40 2013 +0000
+@@ -612,7 +612,7 @@
+ try {
+ File.createTempFile(prefix, suffix, directory);
+ } catch (IOException ex) {
+- if ("Unable to create temporary file".equals(ex.getMessage()))
++ if (ExceptionMsg.equals(ex.getMessage()))
+ exceptionThrown = true;
+ }
+ }
+diff -r 8ad2eb12bf42 -r 8459b68eb028 test/java/io/File/createTempFile/SpecialTempFile.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jdk/test/java/io/File/createTempFile/SpecialTempFile.java Tue Oct 29 03:49:40 2013 +0000
+@@ -0,0 +1,80 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++/*
++ * @test
++ * @bug 8013827 8011950
++ * @summary Check whether File.createTempFile can handle special parameters
++ * on Windows platforms
++ * @author Dan Xu
++ */
++
++import java.io.File;
++import java.io.IOException;
++
++public class SpecialTempFile {
++
++ private static void test(String name, String[] prefix, String[] suffix) {
++ if (prefix == null || suffix == null
++ || prefix.length != suffix.length)
++ {
++ return;
++ }
++
++ final String exceptionMsg = "Unable to create temporary file";
++ final String errMsg = "IOException is expected";
++
++ for (int i = 0; i < prefix.length; i++) {
++ boolean exceptionThrown = false;
++ File f = null;
++ System.out.println("In test " + name
++ + ", creating temp file with prefix, "
++ + prefix[i] + ", suffix, " + suffix[i]);
++ try {
++ f = File.createTempFile(prefix[i], suffix[i]);
++ } catch (IOException e) {
++ if (exceptionMsg.equals(e.getMessage()))
++ exceptionThrown = true;
++ else
++ System.out.println("Wrong error message:" + e.getMessage());
++ }
++ if (!exceptionThrown || f != null)
++ throw new RuntimeException(errMsg);
++ }
++ }
++
++ public static void main(String[] args) throws Exception {
++ if (!System.getProperty("os.name").startsWith("Windows"))
++ return;
++
++ // Test JDK-8013827
++ String[] resvPre = { "LPT1.package.zip", "com7.4.package.zip" };
++ String[] resvSuf = { ".temp", ".temp" };
++ test("ReservedName", resvPre, resvSuf);
++
++ // Test JDK-8011950
++ String[] slashPre = { "///..///", "temp", "///..///" };
++ String[] slashSuf = { ".temp", "///..///..", "///..///.." };
++ test("SlashedName", slashPre, slashSuf);
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8014085-better_serialization.patch b/java/openjdk6/files/icedtea/openjdk/8014085-better_serialization.patch
new file mode 100644
index 000000000000..bdfc1b1c89ec
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014085-better_serialization.patch
@@ -0,0 +1,412 @@
+# HG changeset patch
+# User jbachorik
+# Date 1371711107 -7200
+# Thu Jun 20 08:51:47 2013 +0200
+# Node ID a9be60a78488c7b261b92d927d1272afe2484e6b
+# Parent d10e47deb098d4af5d58a8bfe92dc8033e5ef6f7
+8014085: Better serialization support in JMX classes
+Reviewed-by: alanb, dfuchs, skoivu
+
+diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/MBeanNotificationInfo.java
+--- jdk/src/share/classes/javax/management/MBeanNotificationInfo.java Tue Oct 15 16:47:11 2013 +0100
++++ jdk/src/share/classes/javax/management/MBeanNotificationInfo.java Thu Jun 20 08:51:47 2013 +0200
+@@ -25,6 +25,9 @@
+
+ package javax.management;
+
++import java.io.IOException;
++import java.io.InvalidObjectException;
++import java.io.ObjectInputStream;
+ import java.util.Arrays;
+
+ /**
+@@ -67,7 +70,7 @@
+ /**
+ * @serial The different types of the notification.
+ */
+- private final String[] types;
++ private String[] types;
+
+ /** @see MBeanInfo#arrayGettersSafe */
+ private final transient boolean arrayGettersSafe;
+@@ -114,9 +117,8 @@
+ notifType, though it doesn't explicitly allow it
+ either. */
+
+- if (notifTypes == null)
+- notifTypes = NO_TYPES;
+- this.types = notifTypes;
++ this.types = (notifTypes != null && notifTypes.length > 0) ?
++ notifTypes.clone() : NO_TYPES;
+ this.arrayGettersSafe =
+ MBeanInfo.arrayGettersSafe(this.getClass(),
+ MBeanNotificationInfo.class);
+@@ -203,4 +205,16 @@
+ hash ^= types[i].hashCode();
+ return hash;
+ }
++
++ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
++ ObjectInputStream.GetField gf = ois.readFields();
++ String[] t = (String[])gf.get("types", null);
++
++ if (t == null) {
++ throw new InvalidObjectException("Trying to deserialize an invalid " +
++ "instance of " + MBeanNotificationInfo.class +
++ "[types=null]");
++ }
++ types = t.length == 0 ? t : t.clone();
++ }
+ }
+diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/remote/JMXPrincipal.java
+--- jdk/src/share/classes/javax/management/remote/JMXPrincipal.java Tue Oct 15 16:47:11 2013 +0100
++++ jdk/src/share/classes/javax/management/remote/JMXPrincipal.java Thu Jun 20 08:51:47 2013 +0200
+@@ -26,6 +26,9 @@
+
+ package javax.management.remote;
+
++import java.io.IOException;
++import java.io.InvalidObjectException;
++import java.io.ObjectInputStream;
+ import java.io.Serializable;
+ import java.security.Principal;
+
+@@ -64,9 +67,7 @@
+ * <code>null</code>.
+ */
+ public JMXPrincipal(String name) {
+- if (name == null)
+- throw new NullPointerException("illegal null input");
+-
++ validate(name);
+ this.name = name;
+ }
+
+@@ -130,4 +131,20 @@
+ public int hashCode() {
+ return name.hashCode();
+ }
++
++ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
++ ObjectInputStream.GetField gf = ois.readFields();
++ String principalName = (String)gf.get("name", null);
++ try {
++ validate(principalName);
++ this.name = principalName;
++ } catch (NullPointerException e) {
++ throw new InvalidObjectException(e.getMessage());
++ }
++ }
++
++ private static void validate(String name) throws NullPointerException {
++ if (name == null)
++ throw new NullPointerException("illegal null input");
++ }
+ }
+diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/remote/JMXServiceURL.java
+--- jdk/src/share/classes/javax/management/remote/JMXServiceURL.java Tue Oct 15 16:47:11 2013 +0100
++++ jdk/src/share/classes/javax/management/remote/JMXServiceURL.java Thu Jun 20 08:51:47 2013 +0200
+@@ -29,6 +29,9 @@
+
+ import com.sun.jmx.remote.util.ClassLogger;
+ import com.sun.jmx.remote.util.EnvHelp;
++import java.io.IOException;
++import java.io.InvalidObjectException;
++import java.io.ObjectInputStream;
+
+ import java.io.Serializable;
+ import java.net.InetAddress;
+@@ -299,7 +302,7 @@
+ If we're given an explicit host name that is illegal we
+ have to reject it. (Bug 5057532.) */
+ try {
+- validateHost(host);
++ validateHost(host, port);
+ } catch (MalformedURLException e) {
+ if (logger.fineOn()) {
+ logger.fine("JMXServiceURL",
+@@ -338,36 +341,82 @@
+ validate();
+ }
+
+- private void validate() throws MalformedURLException {
++ private static final String INVALID_INSTANCE_MSG =
++ "Trying to deserialize an invalid instance of JMXServiceURL";
++ private void readObject(ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
++ ObjectInputStream.GetField gf = inputStream.readFields();
++ String h = (String)gf.get("host", null);
++ int p = (int)gf.get("port", -1);
++ String proto = (String)gf.get("protocol", null);
++ String url = (String)gf.get("urlPath", null);
+
++ if (proto == null || url == null || h == null) {
++ StringBuilder sb = new StringBuilder(INVALID_INSTANCE_MSG).append('[');
++ boolean empty = true;
++ if (proto == null) {
++ sb.append("protocol=null");
++ empty = false;
++ }
++ if (h == null) {
++ sb.append(empty ? "" : ",").append("host=null");
++ empty = false;
++ }
++ if (url == null) {
++ sb.append(empty ? "" : ",").append("urlPath=null");
++ }
++ sb.append(']');
++ throw new InvalidObjectException(sb.toString());
++ }
++
++ if (h.contains("[") || h.contains("]")) {
++ throw new InvalidObjectException("Invalid host name: " + h);
++ }
++
++ try {
++ validate(proto, h, p, url);
++ this.protocol = proto;
++ this.host = h;
++ this.port = p;
++ this.urlPath = url;
++ } catch (MalformedURLException e) {
++ throw new InvalidObjectException(INVALID_INSTANCE_MSG + ": " +
++ e.getMessage());
++ }
++
++ }
++
++ private void validate(String proto, String h, int p, String url)
++ throws MalformedURLException {
+ // Check protocol
+-
+- final int protoEnd = indexOfFirstNotInSet(protocol, protocolBitSet, 0);
+- if (protoEnd == 0 || protoEnd < protocol.length()
+- || !alphaBitSet.get(protocol.charAt(0))) {
++ final int protoEnd = indexOfFirstNotInSet(proto, protocolBitSet, 0);
++ if (protoEnd == 0 || protoEnd < proto.length()
++ || !alphaBitSet.get(proto.charAt(0))) {
+ throw new MalformedURLException("Missing or invalid protocol " +
+- "name: \"" + protocol + "\"");
++ "name: \"" + proto + "\"");
+ }
+
+ // Check host
+-
+- validateHost();
++ validateHost(h, p);
+
+ // Check port
+-
+- if (port < 0)
+- throw new MalformedURLException("Bad port: " + port);
++ if (p < 0)
++ throw new MalformedURLException("Bad port: " + p);
+
+ // Check URL path
+-
+- if (urlPath.length() > 0) {
+- if (!urlPath.startsWith("/") && !urlPath.startsWith(";"))
+- throw new MalformedURLException("Bad URL path: " + urlPath);
++ if (url.length() > 0) {
++ if (!url.startsWith("/") && !url.startsWith(";"))
++ throw new MalformedURLException("Bad URL path: " + url);
+ }
+ }
+
+- private void validateHost() throws MalformedURLException {
+- if (host.length() == 0) {
++ private void validate() throws MalformedURLException {
++ validate(this.protocol, this.host, this.port, this.urlPath);
++ }
++
++ private static void validateHost(String h, int port)
++ throws MalformedURLException {
++
++ if (h.length() == 0) {
+ if (port != 0) {
+ throw new MalformedURLException("Cannot give port number " +
+ "without host name");
+@@ -375,12 +424,6 @@
+ return;
+ }
+
+- validateHost(host);
+- }
+-
+- private static void validateHost(String h)
+- throws MalformedURLException {
+-
+ if (isNumericIPv6Address(h)) {
+ /* We assume J2SE >= 1.4 here. Otherwise you can't
+ use the address anyway. We can't call
+@@ -670,22 +713,22 @@
+ /**
+ * The value returned by {@link #getProtocol()}.
+ */
+- private final String protocol;
++ private String protocol;
+
+ /**
+ * The value returned by {@link #getHost()}.
+ */
+- private final String host;
++ private String host;
+
+ /**
+ * The value returned by {@link #getPort()}.
+ */
+- private final int port;
++ private int port;
+
+ /**
+ * The value returned by {@link #getURLPath()}.
+ */
+- private final String urlPath;
++ private String urlPath;
+
+ /**
+ * Cached result of {@link #toString()}.
+diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/remote/NotificationResult.java
+--- jdk/src/share/classes/javax/management/remote/NotificationResult.java Tue Oct 15 16:47:11 2013 +0100
++++ jdk/src/share/classes/javax/management/remote/NotificationResult.java Thu Jun 20 08:51:47 2013 +0200
+@@ -25,6 +25,9 @@
+
+ package javax.management.remote;
+
++import java.io.IOException;
++import java.io.InvalidObjectException;
++import java.io.ObjectInputStream;
+ import java.io.Serializable;
+
+ /**
+@@ -76,17 +79,7 @@
+ public NotificationResult(long earliestSequenceNumber,
+ long nextSequenceNumber,
+ TargetedNotification[] targetedNotifications) {
+- if (targetedNotifications == null) {
+- final String msg = "Notifications null";
+- throw new IllegalArgumentException(msg);
+- }
+-
+- if (earliestSequenceNumber < 0 || nextSequenceNumber < 0)
+- throw new IllegalArgumentException("Bad sequence numbers");
+- /* We used to check nextSequenceNumber >= earliestSequenceNumber
+- here. But in fact the opposite can legitimately be true if
+- notifications have been lost. */
+-
++ validate(targetedNotifications, earliestSequenceNumber, nextSequenceNumber);
+ this.earliestSequenceNumber = earliestSequenceNumber;
+ this.nextSequenceNumber = nextSequenceNumber;
+ this.targetedNotifications = (targetedNotifications.length == 0 ? targetedNotifications : targetedNotifications.clone());
+@@ -138,7 +131,39 @@
+ getTargetedNotifications().length;
+ }
+
+- private final long earliestSequenceNumber;
+- private final long nextSequenceNumber;
+- private final TargetedNotification[] targetedNotifications;
++ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
++ ObjectInputStream.GetField gf = ois.readFields();
++ TargetedNotification[] tNotifs = (TargetedNotification[])gf.get("targetedNotifications", null);
++ long snStart = gf.get("earliestSequenceNumber", -1L);
++ long snNext = gf.get("nextSequenceNumber", -1L);
++ try {
++ validate(tNotifs, snStart, snNext);
++
++ this.targetedNotifications = tNotifs.length == 0 ? tNotifs : tNotifs.clone();
++ this.earliestSequenceNumber = snStart;
++ this.nextSequenceNumber = snNext;
++ } catch (IllegalArgumentException e) {
++ throw new InvalidObjectException(e.getMessage());
++ }
++ }
++
++ private long earliestSequenceNumber;
++ private long nextSequenceNumber;
++ private TargetedNotification[] targetedNotifications;
++
++ private static void validate(TargetedNotification[] targetedNotifications,
++ long earliestSequenceNumber,
++ long nextSequenceNumber)
++ throws IllegalArgumentException {
++ if (targetedNotifications == null) {
++ final String msg = "Notifications null";
++ throw new IllegalArgumentException(msg);
++ }
++
++ if (earliestSequenceNumber < 0 || nextSequenceNumber < 0)
++ throw new IllegalArgumentException("Bad sequence numbers");
++ /* We used to check nextSequenceNumber >= earliestSequenceNumber
++ here. But in fact the opposite can legitimately be true if
++ notifications have been lost. */
++ }
+ }
+diff -r d10e47deb098 -r a9be60a78488 src/share/classes/javax/management/remote/TargetedNotification.java
+--- jdk/src/share/classes/javax/management/remote/TargetedNotification.java Tue Oct 15 16:47:11 2013 +0100
++++ jdk/src/share/classes/javax/management/remote/TargetedNotification.java Thu Jun 20 08:51:47 2013 +0200
+@@ -26,6 +26,9 @@
+
+ package javax.management.remote;
+
++import java.io.IOException;
++import java.io.InvalidObjectException;
++import java.io.ObjectInputStream;
+ import java.io.Serializable;
+ import javax.management.Notification;
+
+@@ -73,12 +76,9 @@
+ */
+ public TargetedNotification(Notification notification,
+ Integer listenerID) {
++ validate(notification, listenerID);
+ // If we replace integer with int...
+ // this(notification,intValue(listenerID));
+- if (notification == null) throw new
+- IllegalArgumentException("Invalid notification: null");
+- if (listenerID == null) throw new
+- IllegalArgumentException("Invalid listener ID: null");
+ this.notif = notification;
+ this.id = listenerID;
+ }
+@@ -115,13 +115,13 @@
+ * @serial A notification to transmit to the other side.
+ * @see #getNotification()
+ **/
+- private final Notification notif;
++ private Notification notif;
+ /**
+ * @serial The ID of the listener to which the notification is
+ * targeted.
+ * @see #getListenerID()
+ **/
+- private final Integer id;
++ private Integer id;
+ //private final int id;
+
+ // Needed if we use int instead of Integer...
+@@ -130,4 +130,26 @@
+ // IllegalArgumentException("Invalid listener ID: null");
+ // return id.intValue();
+ // }
++
++ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
++ ObjectInputStream.GetField gf = ois.readFields();
++ Notification notification = (Notification)gf.get("notif", null);
++ Integer listenerId = (Integer)gf.get("id", null);
++ try {
++ validate(notification, listenerId);
++ this.notif = notification;
++ this.id = listenerId;
++ } catch (IllegalArgumentException e) {
++ throw new InvalidObjectException(e.getMessage());
++ }
++ }
++
++ private static void validate(Notification notif, Integer id) throws IllegalArgumentException {
++ if (notif == null) {
++ throw new IllegalArgumentException("Invalid notification: null");
++ }
++ if (id == null) {
++ throw new IllegalArgumentException("Invalid listener ID: null");
++ }
++ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8014093-improve_image_parsing.patch b/java/openjdk6/files/icedtea/openjdk/8014093-improve_image_parsing.patch
new file mode 100644
index 000000000000..d0553950951d
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014093-improve_image_parsing.patch
@@ -0,0 +1,719 @@
+# HG changeset patch
+# User bae
+# Date 1368794871 -14400
+# Fri May 17 16:47:51 2013 +0400
+# Node ID 5405d79569f76d1285fd3c840489477a81bd9eff
+# Parent a9be60a78488c7b261b92d927d1272afe2484e6b
+8014093: Improve parsing of images
+Reviewed-by: prr
+
+diff -r a9be60a78488 -r 5405d79569f7 src/share/native/sun/awt/image/awt_parseImage.c
+--- jdk/src/share/native/sun/awt/image/awt_parseImage.c Thu Jun 20 08:51:47 2013 +0200
++++ jdk/src/share/native/sun/awt/image/awt_parseImage.c Fri May 17 16:47:51 2013 +0400
+@@ -797,363 +797,204 @@
+ return 1;
+ }
+
+-/*
+- * This routine will fill in a buffer of data for either 1 band or all
+- * bands (if band == -1).
+- */
+ #define MAX_TO_GRAB (10240)
+
+-int awt_getPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
+- unsigned char *bufferP) {
+- int w = rasterP->width;
+- int h = rasterP->height;
+- int numBands = rasterP->numBands;
++typedef union {
++ void *pv;
++ unsigned char *pb;
++ unsigned short *ps;
++} PixelData_t;
++
++
++int awt_getPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP) {
++ const int w = rasterP->width;
++ const int h = rasterP->height;
++ const int numBands = rasterP->numBands;
+ int y;
+ int i;
+- int maxLines = (h < MAX_TO_GRAB/w ? h : MAX_TO_GRAB/w);
++ int maxLines;
+ jobject jsm;
+- int off;
++ int off = 0;
+ jarray jdata = NULL;
+ jobject jdatabuffer;
+ int *dataP;
+- int maxBytes = w;
++ int maxSamples;
++ PixelData_t p;
++
++ if (bufferP == NULL) {
++ return -1;
++ }
++
++ if (rasterP->dataType != BYTE_DATA_TYPE &&
++ rasterP->dataType != SHORT_DATA_TYPE)
++ {
++ return -1;
++ }
++
++ p.pv = bufferP;
++
++ if (!SAFE_TO_MULT(w, numBands)) {
++ return -1;
++ }
++ maxSamples = w * numBands;
++
++ maxLines = maxSamples > MAX_TO_GRAB ? 1 : (MAX_TO_GRAB / maxSamples);
++ if (maxLines > h) {
++ maxLines = h;
++ }
++
++ if (!SAFE_TO_MULT(maxSamples, maxLines)) {
++ return -1;
++ }
++
++ maxSamples *= maxLines;
+
+ jsm = (*env)->GetObjectField(env, rasterP->jraster, g_RasterSampleModelID);
+ jdatabuffer = (*env)->GetObjectField(env, rasterP->jraster,
+ g_RasterDataBufferID);
+- jdata = (*env)->NewIntArray(env, maxBytes*rasterP->numBands*maxLines);
++
++ jdata = (*env)->NewIntArray(env, maxSamples);
+ if (JNU_IsNull(env, jdata)) {
+ JNU_ThrowOutOfMemoryError(env, "Out of Memory");
+ return -1;
+ }
+
+- /* Here is the generic code */
+- if (band >= 0) {
+- int dOff;
+- if (band >= numBands) {
++ for (y = 0; y < h; y += maxLines) {
++ if (y + maxLines > h) {
++ maxLines = h - y;
++ maxSamples = w * numBands * maxLines;
++ }
++
++ (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
++ 0, y, w,
++ maxLines, jdata, jdatabuffer);
++
++ if ((*env)->ExceptionOccurred(env)) {
+ (*env)->DeleteLocalRef(env, jdata);
+- JNU_ThrowInternalError(env, "Band out of range.");
+ return -1;
+ }
+- off = 0;
+- for (y=0; y < h; ) {
+- (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
+- 0, y, w,
+- maxLines, jdata, jdatabuffer);
+- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+- NULL);
+- if (dataP == NULL) {
+- (*env)->DeleteLocalRef(env, jdata);
+- return -1;
+- }
+- dOff = band;
+- for (i=0; i < maxBytes; i++, dOff += numBands) {
+- bufferP[off++] = (unsigned char) dataP[dOff];
+- }
+
+- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+- JNI_ABORT);
+-
+- if (y+maxLines < h) {
+- y += maxLines;
+- }
+- else {
+- y++;
+- maxBytes = w;
+- }
+- }
+- }
+- else {
+- off = 0;
+- maxBytes *= numBands;
+- for (y=0; y < h; ) {
+- (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
+- 0, y, w,
+- maxLines, jdata, jdatabuffer);
+- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+- NULL);
+- if (dataP == NULL) {
+- (*env)->DeleteLocalRef(env, jdata);
+- return -1;
+- }
+- for (i=0; i < maxBytes; i++) {
+- bufferP[off++] = (unsigned char) dataP[i];
+- }
+-
+- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+- JNI_ABORT);
+-
+- if (y+maxLines < h) {
+- y += maxLines;
+- }
+- else {
+- y++;
+- maxBytes = w*numBands;
+- }
++ dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
++ NULL);
++ if (dataP == NULL) {
++ (*env)->DeleteLocalRef(env, jdata);
++ return -1;
+ }
+
++ switch (rasterP->dataType) {
++ case BYTE_DATA_TYPE:
++ for (i = 0; i < maxSamples; i ++) {
++ p.pb[off++] = (unsigned char) dataP[i];
++ }
++ break;
++ case SHORT_DATA_TYPE:
++ for (i = 0; i < maxSamples; i ++) {
++ p.ps[off++] = (unsigned short) dataP[i];
++ }
++ break;
++ }
++
++ (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
++ JNI_ABORT);
+ }
+ (*env)->DeleteLocalRef(env, jdata);
+
+- return 0;
++ return 1;
+ }
+-int awt_setPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
+- unsigned char *bufferP) {
+- int w = rasterP->width;
+- int h = rasterP->height;
+- int numBands = rasterP->numBands;
++
++int awt_setPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP) {
++ const int w = rasterP->width;
++ const int h = rasterP->height;
++ const int numBands = rasterP->numBands;
++
+ int y;
+ int i;
+- int maxLines = (h < MAX_TO_GRAB/w ? h : MAX_TO_GRAB/w);
++ int maxLines;
+ jobject jsm;
+- int off;
++ int off = 0;
+ jarray jdata = NULL;
+ jobject jdatabuffer;
+ int *dataP;
+- int maxBytes = w;
++ int maxSamples;
++ PixelData_t p;
++
++ if (bufferP == NULL) {
++ return -1;
++ }
++
++ if (rasterP->dataType != BYTE_DATA_TYPE &&
++ rasterP->dataType != SHORT_DATA_TYPE)
++ {
++ return -1;
++ }
++
++ p.pv = bufferP;
++
++ if (!SAFE_TO_MULT(w, numBands)) {
++ return -1;
++ }
++ maxSamples = w * numBands;
++
++ maxLines = maxSamples > MAX_TO_GRAB ? 1 : (MAX_TO_GRAB / maxSamples);
++ if (maxLines > h) {
++ maxLines = h;
++ }
++
++ if (!SAFE_TO_MULT(maxSamples, maxLines)) {
++ return -1;
++ }
++
++ maxSamples *= maxLines;
+
+ jsm = (*env)->GetObjectField(env, rasterP->jraster, g_RasterSampleModelID);
+ jdatabuffer = (*env)->GetObjectField(env, rasterP->jraster,
+ g_RasterDataBufferID);
+- /* Here is the generic code */
+- jdata = (*env)->NewIntArray(env, maxBytes*rasterP->numBands*maxLines);
++
++ jdata = (*env)->NewIntArray(env, maxSamples);
+ if (JNU_IsNull(env, jdata)) {
+ JNU_ThrowOutOfMemoryError(env, "Out of Memory");
+ return -1;
+ }
+- if (band >= 0) {
+- int dOff;
+- if (band >= numBands) {
++
++ for (y = 0; y < h; y += maxLines) {
++ if (y + maxLines > h) {
++ maxLines = h - y;
++ maxSamples = w * numBands * maxLines;
++ }
++ dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
++ NULL);
++ if (dataP == NULL) {
+ (*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) {
+- maxBytes = w*numBands;
+- maxLines = h - y;
++
++ switch (rasterP->dataType) {
++ case BYTE_DATA_TYPE:
++ for (i = 0; i < maxSamples; i ++) {
++ dataP[i] = p.pb[off++];
+ }
+- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+- NULL);
+- if (dataP == NULL) {
+- (*env)->DeleteLocalRef(env, jdata);
+- return -1;
++ break;
++ case SHORT_DATA_TYPE:
++ for (i = 0; i < maxSamples; i ++) {
++ dataP[i] = p.ps[off++];
+ }
+- dOff = band;
+- for (i=0; i < maxBytes; i++, dOff += numBands) {
+- dataP[dOff] = bufferP[off++];
+- }
+-
+- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+- JNI_ABORT);
+-
+- (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
+- 0, y, w,
+- maxLines, jdata, jdatabuffer);
+- }
+- }
+- else {
+- off = 0;
+- maxBytes *= numBands;
+- for (y=0; y < h; y+=maxLines) {
+- if (y+maxLines > h) {
+- maxBytes = w*numBands;
+- maxLines = h - y;
+- }
+- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+- NULL);
+- if (dataP == NULL) {
+- (*env)->DeleteLocalRef(env, jdata);
+- return -1;
+- }
+- for (i=0; i < maxBytes; i++) {
+- dataP[i] = bufferP[off++];
+- }
+-
+- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+- JNI_ABORT);
+-
+- (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
+- 0, y, w,
+- maxLines, jdata, jdatabuffer);
++ break;
+ }
+
++ (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
++ JNI_ABORT);
++
++ (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
++ 0, y, w,
++ maxLines, jdata, jdatabuffer);
++
++ if ((*env)->ExceptionOccurred(env)) {
++ (*env)->DeleteLocalRef(env, jdata);
++ return -1;
++ }
+ }
+
+ (*env)->DeleteLocalRef(env, jdata);
+
+- return 0;
++ return 1;
+ }
+-int awt_getPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
+- unsigned short *bufferP) {
+- int w = rasterP->width;
+- int h = rasterP->height;
+- int numBands = rasterP->numBands;
+- int y;
+- int i;
+- int maxLines = (h < MAX_TO_GRAB/w ? h : MAX_TO_GRAB/w);
+- jobject jsm;
+- int off;
+- jarray jdata = NULL;
+- jobject jdatabuffer;
+- int *dataP;
+- int maxBytes = w*maxLines;
+-
+- jsm = (*env)->GetObjectField(env, rasterP->jraster, g_RasterSampleModelID);
+- jdatabuffer = (*env)->GetObjectField(env, rasterP->jraster,
+- g_RasterDataBufferID);
+- jdata = (*env)->NewIntArray(env, maxBytes*rasterP->numBands*maxLines);
+- if (JNU_IsNull(env, jdata)) {
+- JNU_ThrowOutOfMemoryError(env, "Out of Memory");
+- return -1;
+- }
+- /* Here is the generic code */
+- 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) {
+- maxBytes = w*numBands;
+- maxLines = h - y;
+- }
+- (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
+- 0, y, w,
+- maxLines, jdata, jdatabuffer);
+- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+- NULL);
+- if (dataP == NULL) {
+- (*env)->DeleteLocalRef(env, jdata);
+- return -1;
+- }
+-
+- dOff = band;
+- for (i=0; i < maxBytes; i++, dOff += numBands) {
+- bufferP[off++] = (unsigned short) dataP[dOff];
+- }
+-
+- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+- JNI_ABORT);
+- }
+- }
+- else {
+- off = 0;
+- maxBytes *= numBands;
+- for (y=0; y < h; y+=maxLines) {
+- if (y+maxLines > h) {
+- maxBytes = w*numBands;
+- maxLines = h - y;
+- }
+- (*env)->CallObjectMethod(env, jsm, g_SMGetPixelsMID,
+- 0, y, w,
+- maxLines, jdata, jdatabuffer);
+- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+- NULL);
+- if (dataP == NULL) {
+- (*env)->DeleteLocalRef(env, jdata);
+- return -1;
+- }
+- for (i=0; i < maxBytes; i++) {
+- bufferP[off++] = (unsigned short) dataP[i];
+- }
+-
+- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+- JNI_ABORT);
+- }
+-
+- }
+-
+- (*env)->DeleteLocalRef(env, jdata);
+- return 0;
+-}
+-int awt_setPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
+- unsigned short *bufferP) {
+- int w = rasterP->width;
+- int h = rasterP->height;
+- int numBands = rasterP->numBands;
+- int y;
+- int i;
+- int maxLines = (h < MAX_TO_GRAB/w ? h : MAX_TO_GRAB/w);
+- jobject jsm;
+- int off;
+- jarray jdata = NULL;
+- jobject jdatabuffer;
+- int *dataP;
+- int maxBytes = w;
+-
+- 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)) {
+- JNU_ThrowOutOfMemoryError(env, "Out of Memory");
+- return -1;
+- }
+- if (band >= 0) {
+- int dOff;
+- off = 0;
+- for (y=0; y < h; y+=maxLines) {
+- if (y+maxLines > h) {
+- maxBytes = w*numBands;
+- maxLines = h - y;
+- }
+- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+- NULL);
+- if (dataP == NULL) {
+- (*env)->DeleteLocalRef(env, jdata);
+- return -1;
+- }
+- dOff = band;
+- for (i=0; i < maxBytes; i++, dOff += numBands) {
+- dataP[dOff] = bufferP[off++];
+- }
+-
+- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+- JNI_ABORT);
+-
+- (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
+- 0, y, w,
+- maxLines, jdata, jdatabuffer);
+- }
+- }
+- else {
+- off = 0;
+- maxBytes *= numBands;
+- for (y=0; y < h; y+=maxLines) {
+- if (y+maxLines > h) {
+- maxBytes = w*numBands;
+- maxLines = h - y;
+- }
+- dataP = (int *) (*env)->GetPrimitiveArrayCritical(env, jdata,
+- NULL);
+- if (dataP == NULL) {
+- (*env)->DeleteLocalRef(env, jdata);
+- return -1;
+- }
+- for (i=0; i < maxBytes; i++) {
+- dataP[i] = bufferP[off++];
+- }
+-
+- (*env)->ReleasePrimitiveArrayCritical(env, jdata, dataP,
+- JNI_ABORT);
+-
+- (*env)->CallVoidMethod(env, jsm, g_SMSetPixelsMID,
+- 0, y, w,
+- maxLines, jdata, jdatabuffer);
+- }
+-
+- }
+-
+- (*env)->DeleteLocalRef(env, jdata);
+- return 0;
+-}
+diff -r a9be60a78488 -r 5405d79569f7 src/share/native/sun/awt/image/awt_parseImage.h
+--- jdk/src/share/native/sun/awt/image/awt_parseImage.h Thu Jun 20 08:51:47 2013 +0200
++++ jdk/src/share/native/sun/awt/image/awt_parseImage.h Fri May 17 16:47:51 2013 +0400
+@@ -188,13 +188,8 @@
+
+ void awt_freeParsedImage(BufImageS_t *imageP, int freeImageP);
+
+-int awt_getPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
+- unsigned char *bufferP);
+-int awt_setPixelByte(JNIEnv *env, int band, RasterS_t *rasterP,
+- unsigned char *bufferP);
+-int awt_getPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
+- unsigned short *bufferP);
+-int awt_setPixelShort(JNIEnv *env, int band, RasterS_t *rasterP,
+- unsigned short *bufferP);
++int awt_getPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP);
++
++int awt_setPixels(JNIEnv *env, RasterS_t *rasterP, void *bufferP);
+
+ #endif /* AWT_PARSE_IMAGE_H */
+diff -r a9be60a78488 -r 5405d79569f7 src/share/native/sun/awt/medialib/awt_ImagingLib.c
+--- jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c Thu Jun 20 08:51:47 2013 +0200
++++ jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c Fri May 17 16:47:51 2013 +0400
+@@ -700,22 +700,7 @@
+
+ /* Means that we couldn't write directly into the destination buffer */
+ if (ddata == NULL) {
+- unsigned char *bdataP;
+- unsigned short *sdataP;
+-
+- /* Punt for now */
+- switch (dstRasterP->dataType) {
+- case BYTE_DATA_TYPE:
+- bdataP = (unsigned char *) mlib_ImageGetData(dst);
+- retStatus = (awt_setPixelByte(env, -1, dstRasterP, bdataP) >= 0) ;
+- break;
+- case SHORT_DATA_TYPE:
+- sdataP = (unsigned short *) mlib_ImageGetData(dst);
+- retStatus = (awt_setPixelShort(env, -1, dstRasterP, sdataP) >= 0) ;
+- break;
+- default:
+- retStatus = 0;
+- }
++ retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
+ }
+
+ /* Release the pinned memory */
+@@ -1119,24 +1104,9 @@
+
+ /* Means that we couldn't write directly into the destination buffer */
+ if (ddata == NULL) {
+- unsigned char *bdataP;
+- unsigned short *sdataP;
+-
+ /* Need to store it back into the array */
+ if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
+- /* Punt for now */
+- switch (dst->type) {
+- case MLIB_BYTE:
+- bdataP = (unsigned char *) mlib_ImageGetData(dst);
+- retStatus = (awt_setPixelByte(env, -1, dstRasterP, bdataP) >= 0) ;
+- break;
+- case MLIB_SHORT:
+- sdataP = (unsigned short *) mlib_ImageGetData(dst);
+- retStatus = (awt_setPixelShort(env, -1, dstRasterP, sdataP) >= 0) ;
+- break;
+- default:
+- retStatus = 0;
+- }
++ retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
+ }
+ }
+
+@@ -1705,21 +1675,7 @@
+ * the destination buffer
+ */
+ if (ddata == NULL) {
+- unsigned char* bdataP;
+- unsigned short* sdataP;
+-
+- switch (dstRasterP->dataType) {
+- case BYTE_DATA_TYPE:
+- bdataP = (unsigned char *) mlib_ImageGetData(dst);
+- retStatus = (awt_setPixelByte(env, -1, dstRasterP, bdataP) >= 0) ;
+- break;
+- case SHORT_DATA_TYPE:
+- sdataP = (unsigned short *) mlib_ImageGetData(dst);
+- retStatus = (awt_setPixelShort(env, -1, dstRasterP, sdataP) >= 0) ;
+- break;
+- default:
+- retStatus = 0;
+- }
++ retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
+ }
+
+ /* Release the LUT */
+@@ -2299,7 +2255,6 @@
+ mlib_image **mlibImagePP, void **dataPP, int isSrc) {
+ void *dataP;
+ unsigned char *cDataP;
+- unsigned short *sdataP;
+ int dataType = BYTE_DATA_TYPE;
+ int width;
+ int height;
+@@ -2485,8 +2440,7 @@
+ return -1;
+ }
+ if (isSrc) {
+- cDataP = (unsigned char *) mlib_ImageGetData(*mlibImagePP);
+- if (awt_getPixelByte(env, -1, rasterP, cDataP) < 0) {
++ if (awt_getPixels(env, rasterP, mlib_ImageGetData(*mlibImagePP)) < 0) {
+ (*sMlibSysFns.deleteImageFP)(*mlibImagePP);
+ return -1;
+ }
+@@ -2500,8 +2454,7 @@
+ return -1;
+ }
+ if (isSrc) {
+- sdataP = (unsigned short *) mlib_ImageGetData(*mlibImagePP);
+- if (awt_getPixelShort(env, -1, rasterP, sdataP) < 0) {
++ if (awt_getPixels(env, rasterP, mlib_ImageGetData(*mlibImagePP)) < 0) {
+ (*sMlibSysFns.deleteImageFP)(*mlibImagePP);
+ return -1;
+ }
+@@ -2551,60 +2504,6 @@
+ }
+ }
+
+-static int
+-storeDstArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
+- mlibHintS_t *hintP, mlib_image *mlibImP, void *ddata) {
+- RasterS_t *rasterP = &dstP->raster;
+-
+- /* Nothing to do since it is the same image type */
+- if (srcP->imageType == dstP->imageType
+- && srcP->imageType != java_awt_image_BufferedImage_TYPE_CUSTOM
+- && srcP->imageType != java_awt_image_BufferedImage_TYPE_BYTE_INDEXED
+- && srcP->imageType != java_awt_image_BufferedImage_TYPE_BYTE_BINARY) {
+- /* REMIND: Should check the ICM LUTS to see if it is the same */
+- return 0;
+- }
+-
+- /* These types are compatible with TYPE_INT_RGB */
+- if (srcP->imageType == java_awt_image_BufferedImage_TYPE_INT_RGB
+- && (dstP->imageType == java_awt_image_BufferedImage_TYPE_INT_ARGB ||
+- dstP->imageType == java_awt_image_BufferedImage_TYPE_INT_ARGB_PRE)){
+- return 0;
+- }
+-
+- if (hintP->cvtSrcToDefault &&
+- (srcP->cmodel.isAlphaPre == dstP->cmodel.isAlphaPre)) {
+- if (srcP->cmodel.isAlphaPre) {
+- if (dstP->imageType ==
+- java_awt_image_BufferedImage_TYPE_INT_ARGB_PRE)
+- {
+- return 0;
+- }
+- if (!srcP->cmodel.supportsAlpha &&
+- dstP->imageType == java_awt_image_BufferedImage_TYPE_INT_RGB){
+- return 0;
+- }
+- }
+- else {
+- /* REMIND: */
+- }
+- }
+-
+- if (dstP->cmodel.cmType == DIRECT_CM_TYPE) {
+- /* Just need to move bits */
+- if (mlibImP->type == MLIB_BYTE) {
+- return awt_setPixelByte(env, -1, &dstP->raster,
+- (unsigned char *) mlibImP->data);
+- }
+- else if (mlibImP->type == MLIB_SHORT) {
+- return awt_setPixelByte(env, -1, &dstP->raster,
+- (unsigned char *) mlibImP->data);
+- }
+- }
+-
+- return 0;
+-}
+-
+ #define ERR_BAD_IMAGE_LAYOUT (-2)
+
+ #define CHECK_DST_ARRAY(start_offset, elements_per_pixel) \
+@@ -2717,8 +2616,7 @@
+ }
+ }
+ else if (mlibImP->type == MLIB_SHORT) {
+- return awt_setPixelShort(env, -1, rasterP,
+- (unsigned short *) mlibImP->data);
++ return awt_setPixels(env, rasterP, mlibImP->data);
+ }
+ }
+ else {
diff --git a/java/openjdk6/files/icedtea/openjdk/8014102-improve_image_conversion.patch b/java/openjdk6/files/icedtea/openjdk/8014102-improve_image_conversion.patch
new file mode 100644
index 000000000000..d49c301836ea
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014102-improve_image_conversion.patch
@@ -0,0 +1,190 @@
+# HG changeset patch
+# User bae
+# Date 1369130199 -14400
+# Tue May 21 13:56:39 2013 +0400
+# Node ID d55d40616754cd93aa396719ddfd81bae584d4f0
+# Parent 5405d79569f76d1285fd3c840489477a81bd9eff
+8014102: Improve image conversion
+Reviewed-by: prr
+
+diff -r 5405d79569f7 -r d55d40616754 src/share/native/sun/awt/medialib/awt_ImagingLib.c
+--- jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c Fri May 17 16:47:51 2013 +0400
++++ jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c Tue May 21 13:56:39 2013 +0400
+@@ -1986,21 +1986,25 @@
+ return 0;
+ }
+
++#define NUM_LINES 10
++
+ static int
+ cvtCustomToDefault(JNIEnv *env, BufImageS_t *imageP, int component,
+ unsigned char *dataP) {
+- ColorModelS_t *cmP = &imageP->cmodel;
+- RasterS_t *rasterP = &imageP->raster;
++ const RasterS_t *rasterP = &imageP->raster;
++ const int w = rasterP->width;
++ const int h = rasterP->height;
++
+ int y;
+- jobject jpixels = NULL;
++ jintArray jpixels = NULL;
+ jint *pixels;
+ unsigned char *dP = dataP;
+-#define NUM_LINES 10
+- int numLines = NUM_LINES;
++ int numLines = h > NUM_LINES ? NUM_LINES : h;
++
+ /* it is safe to calculate the scan length, because width has been verified
+ * on creation of the mlib image
+ */
+- int scanLength = rasterP->width * 4;
++ const int scanLength = w * 4;
+
+ int nbytes = 0;
+ if (!SAFE_TO_MULT(numLines, scanLength)) {
+@@ -2009,71 +2013,99 @@
+
+ nbytes = numLines * scanLength;
+
+- for (y=0; y < rasterP->height; y+=numLines) {
+- /* getData, one scanline at a time */
+- if (y+numLines > rasterP->height) {
+- numLines = rasterP->height - y;
+- nbytes = numLines * scanLength;
+- }
+- jpixels = (*env)->CallObjectMethod(env, imageP->jimage,
+- g_BImgGetRGBMID, 0, y,
+- rasterP->width, numLines,
+- jpixels,0, rasterP->width);
+- if (jpixels == NULL) {
+- JNU_ThrowInternalError(env, "Can't retrieve pixels.");
+- return -1;
+- }
+-
+- pixels = (*env)->GetPrimitiveArrayCritical(env, jpixels, NULL);
+- memcpy(dP, pixels, nbytes);
+- dP += nbytes;
+- (*env)->ReleasePrimitiveArrayCritical(env, jpixels, pixels,
+- JNI_ABORT);
+- }
+- return 0;
+-}
+-
+-static int
+-cvtDefaultToCustom(JNIEnv *env, BufImageS_t *imageP, int component,
+- unsigned char *dataP) {
+- ColorModelS_t *cmP = &imageP->cmodel;
+- RasterS_t *rasterP = &imageP->raster;
+- int y;
+- jint *pixels;
+- unsigned char *dP = dataP;
+-#define NUM_LINES 10
+- int numLines = NUM_LINES;
+- int nbytes = rasterP->width*4*NUM_LINES;
+- jintArray jpixels;
+-
+ jpixels = (*env)->NewIntArray(env, nbytes);
+ if (JNU_IsNull(env, jpixels)) {
+ JNU_ThrowOutOfMemoryError(env, "Out of Memory");
+ return -1;
+ }
+
+- for (y=0; y < rasterP->height; y+=NUM_LINES) {
+- if (y+numLines > rasterP->height) {
+- numLines = rasterP->height - y;
+- nbytes = rasterP->width*4*numLines;
++ for (y = 0; y < h; y += numLines) {
++ if (y + numLines > h) {
++ numLines = h - y;
++ nbytes = numLines * scanLength;
+ }
++
++ (*env)->CallObjectMethod(env, imageP->jimage,
++ g_BImgGetRGBMID, 0, y,
++ w, numLines,
++ jpixels, 0, w);
++ if ((*env)->ExceptionOccurred(env)) {
++ (*env)->DeleteLocalRef(env, jpixels);
++ return -1;
++ }
++
+ pixels = (*env)->GetPrimitiveArrayCritical(env, jpixels, NULL);
+ if (pixels == NULL) {
+- /* JNI error */
++ (*env)->DeleteLocalRef(env, jpixels);
+ return -1;
+ }
+
++ memcpy(dP, pixels, nbytes);
++ dP += nbytes;
++
++ (*env)->ReleasePrimitiveArrayCritical(env, jpixels, pixels,
++ JNI_ABORT);
++ }
++
++ /* Need to release the array */
++ (*env)->DeleteLocalRef(env, jpixels);
++
++ return 0;
++}
++
++static int
++cvtDefaultToCustom(JNIEnv *env, BufImageS_t *imageP, int component,
++ unsigned char *dataP) {
++ const RasterS_t *rasterP = &imageP->raster;
++ const int w = rasterP->width;
++ const int h = rasterP->height;
++
++ int y;
++ jintArray jpixels = NULL;
++ jint *pixels;
++ unsigned char *dP = dataP;
++ int numLines = h > NUM_LINES ? NUM_LINES : h;
++
++ /* it is safe to calculate the scan length, because width has been verified
++ * on creation of the mlib image
++ */
++ const int scanLength = w * 4;
++
++ int nbytes = 0;
++ if (!SAFE_TO_MULT(numLines, scanLength)) {
++ return -1;
++ }
++
++ nbytes = numLines * scanLength;
++
++ jpixels = (*env)->NewIntArray(env, nbytes);
++ if (JNU_IsNull(env, jpixels)) {
++ JNU_ThrowOutOfMemoryError(env, "Out of Memory");
++ return -1;
++ }
++
++ for (y = 0; y < h; y += numLines) {
++ if (y + numLines > h) {
++ numLines = h - y;
++ nbytes = numLines * scanLength;
++ }
++
++ pixels = (*env)->GetPrimitiveArrayCritical(env, jpixels, NULL);
++ if (pixels == NULL) {
++ (*env)->DeleteLocalRef(env, jpixels);
++ return -1;
++ }
++
+ memcpy(pixels, dP, nbytes);
+ dP += nbytes;
+
+ (*env)->ReleasePrimitiveArrayCritical(env, jpixels, pixels, 0);
+
+- /* setData, one scanline at a time */
+- /* Fix 4223648, 4184283 */
+ (*env)->CallVoidMethod(env, imageP->jimage, g_BImgSetRGBMID, 0, y,
+- rasterP->width, numLines, jpixels, 0,
+- rasterP->width);
++ w, numLines, jpixels,
++ 0, w);
+ if ((*env)->ExceptionOccurred(env)) {
++ (*env)->DeleteLocalRef(env, jpixels);
+ return -1;
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8014341-better_kerberos_service.patch b/java/openjdk6/files/icedtea/openjdk/8014341-better_kerberos_service.patch
new file mode 100644
index 000000000000..b1b3edc3ee1e
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014341-better_kerberos_service.patch
@@ -0,0 +1,66 @@
+# HG changeset patch
+# User weijun
+# Date 1381852916 -3600
+# Tue Oct 15 17:01:56 2013 +0100
+# Node ID 698fe468e8b9385c2f74709dca823800b32e0b55
+# Parent d55d40616754cd93aa396719ddfd81bae584d4f0
+8014341: Better service from Kerberos servers
+Summary: read incoming data safely and take care of null return value
+Reviewed-by: valeriep, ahgross
+
+diff -r d55d40616754 -r 698fe468e8b9 src/share/classes/sun/security/krb5/KrbKdcReq.java
+--- jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java Tue May 21 13:56:39 2013 +0400
++++ jdk/src/share/classes/sun/security/krb5/KrbKdcReq.java Tue Oct 15 17:01:56 2013 +0100
+@@ -151,11 +151,15 @@
+ savedException = e;
+ }
+ }
+- if (ibuf == null && savedException != null) {
+- if (savedException instanceof IOException) {
+- throw (IOException) savedException;
++ if (ibuf == null) {
++ if (savedException != null) {
++ if (savedException instanceof IOException) {
++ throw (IOException) savedException;
++ } else {
++ throw (KrbException) savedException;
++ }
+ } else {
+- throw (KrbException) savedException;
++ throw new IOException("Cannot get a KDC reply");
+ }
+ }
+ return tempKdc;
+diff -r d55d40616754 -r 698fe468e8b9 src/share/classes/sun/security/krb5/internal/TCPClient.java
+--- jdk/src/share/classes/sun/security/krb5/internal/TCPClient.java Tue May 21 13:56:39 2013 +0400
++++ jdk/src/share/classes/sun/security/krb5/internal/TCPClient.java Tue Oct 15 17:01:56 2013 +0100
+@@ -30,6 +30,8 @@
+
+ package sun.security.krb5.internal;
+
++import sun.misc.IOUtils;
++
+ import java.io.*;
+ import java.net.*;
+
+@@ -79,17 +81,15 @@
+ return null;
+ }
+
+- byte data[] = new byte[len];
+- count = readFully(data, len);
+- if (count != len) {
++ try {
++ return IOUtils.readFully(in, len, true);
++ } catch (IOException ioe) {
+ if (Krb5.DEBUG) {
+ System.out.println(
+ ">>>DEBUG: TCPClient could not read complete packet (" +
+ len + "/" + count + ")");
+ }
+ return null;
+- } else {
+- return data;
+ }
+ }
+
diff --git a/java/openjdk6/files/icedtea/openjdk/8014349-getdeclaredclass_fix.patch b/java/openjdk6/files/icedtea/openjdk/8014349-getdeclaredclass_fix.patch
new file mode 100644
index 000000000000..acf725339cf3
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014349-getdeclaredclass_fix.patch
@@ -0,0 +1,43 @@
+# HG changeset patch
+# User jfranck
+# Date 1382996803 0
+# Mon Oct 28 21:46:43 2013 +0000
+# Node ID e5a4a4ec7b21f3d092d0b29024ff903864d05543
+# Parent 42fd9f22ae5e9aea017af28a2b5ff7a498753e15
+8014349: (cl) Class.getDeclaredClass problematic in some class loader configurations
+Reviewed-by: mchung, ahgross, darcy
+
+diff -r 42fd9f22ae5e -r e5a4a4ec7b21 src/share/classes/java/lang/Class.java
+--- jdk/src/share/classes/java/lang/Class.java Mon Oct 28 20:09:40 2013 +0000
++++ jdk/src/share/classes/java/lang/Class.java Mon Oct 28 21:46:43 2013 +0000
+@@ -1093,7 +1093,17 @@
+ * @return the declaring class for this class
+ * @since JDK1.1
+ */
+- public native Class<?> getDeclaringClass();
++ @CallerSensitive
++ public Class<?> getDeclaringClass() {
++ final Class<?> candidate = getDeclaringClass0();
++
++ if (candidate != null)
++ candidate.checkPackageAccess(
++ ClassLoader.getClassLoader(Reflection.getCallerClass()), true);
++ return candidate;
++ }
++
++ private native Class<?> getDeclaringClass0();
+
+
+ /**
+diff -r 42fd9f22ae5e -r e5a4a4ec7b21 src/share/native/java/lang/Class.c
+--- jdk/src/share/native/java/lang/Class.c Mon Oct 28 20:09:40 2013 +0000
++++ jdk/src/share/native/java/lang/Class.c Mon Oct 28 21:46:43 2013 +0000
+@@ -70,7 +70,7 @@
+ {"getProtectionDomain0", "()" PD, (void *)&JVM_GetProtectionDomain},
+ {"setProtectionDomain0", "(" PD ")V", (void *)&JVM_SetProtectionDomain},
+ {"getDeclaredClasses0", "()[" CLS, (void *)&JVM_GetDeclaredClasses},
+- {"getDeclaringClass", "()" CLS, (void *)&JVM_GetDeclaringClass},
++ {"getDeclaringClass0", "()" CLS, (void *)&JVM_GetDeclaringClass},
+ {"getGenericSignature", "()" STR, (void *)&JVM_GetClassSignature},
+ {"getRawAnnotations", "()" BA, (void *)&JVM_GetClassAnnotations},
+ {"getConstantPool", "()" CPL, (void *)&JVM_GetClassConstantPool},
diff --git a/java/openjdk6/files/icedtea/openjdk/8014530-better_dsp.patch b/java/openjdk6/files/icedtea/openjdk/8014530-better_dsp.patch
new file mode 100644
index 000000000000..bcda8c52a4b4
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014530-better_dsp.patch
@@ -0,0 +1,3121 @@
+# HG changeset patch
+# User joehw
+# Date 1383033689 0
+# Tue Oct 29 08:01:29 2013 +0000
+# Node ID 0927621944ccb163d7dcdea7b94b10dfab58f5f1
+# Parent 3dc769c632a1d6a8f69d2857b3c13c43a83481be
+8014530: Better digital signature processing
+Reviewed-by: alanb, dfuchs, mullan, lancea
+
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/XalanConstants.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/XalanConstants.java Tue Oct 29 08:01:29 2013 +0000
+@@ -0,0 +1,151 @@
++/*
++ * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation. Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.org.apache.xalan.internal;
++
++import com.sun.org.apache.xerces.internal.impl.*;
++
++/**
++ * Commonly used constants.
++ *
++ * @author Huizhe Wang, Oracle
++ *
++ * @version $Id: Constants.java,v 1.14 2011-06-07 04:39:40 joehw Exp $
++ */
++public final class XalanConstants {
++
++ //
++ // Constants
++ //Xerces security manager
++ public static final String SECURITY_MANAGER =
++ "http://apache.org/xml/properties/security-manager";
++
++ //
++ // Implementation limits: API properties
++ //
++ /** Oracle JAXP property prefix ("http://www.oracle.com/xml/jaxp/properties/"). */
++ public static final String ORACLE_JAXP_PROPERTY_PREFIX =
++ "http://www.oracle.com/xml/jaxp/properties/";
++ /**
++ * JDK entity expansion limit; Note that the existing system property
++ * "entityExpansionLimit" with no prefix is still observed
++ */
++ public static final String JDK_ENTITY_EXPANSION_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "entityExpansionLimit";
++
++ /**
++ * JDK element attribute limit; Note that the existing system property
++ * "elementAttributeLimit" with no prefix is still observed
++ */
++ public static final String JDK_ELEMENT_ATTRIBUTE_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "elementAttributeLimit";
++
++ /**
++ * JDK maxOccur limit; Note that the existing system property
++ * "maxOccurLimit" with no prefix is still observed
++ */
++ public static final String JDK_MAX_OCCUR_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "maxOccurLimit";
++
++ /**
++ * JDK total entity size limit
++ */
++ public static final String JDK_TOTAL_ENTITY_SIZE_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "totalEntitySizeLimit";
++
++ /**
++ * JDK maximum general entity size limit
++ */
++ public static final String JDK_GENEAL_ENTITY_SIZE_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "maxGeneralEntitySizeLimit";
++ /**
++ * JDK maximum parameter entity size limit
++ */
++ public static final String JDK_PARAMETER_ENTITY_SIZE_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "maxParameterEntitySizeLimit";
++ /**
++ * JDK maximum XML name limit
++ */
++ public static final String JDK_XML_NAME_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "maxXMLNameLimit";
++ /**
++ * JDK property indicating whether the parser shall print out entity
++ * count information
++ * Value: a string "yes" means print, "no" or any other string means not.
++ */
++ public static final String JDK_ENTITY_COUNT_INFO =
++ ORACLE_JAXP_PROPERTY_PREFIX + "getEntityCountInfo";
++
++ //
++ // Implementation limits: corresponding System Properties of the above
++ // API properties
++ //
++ /**
++ * JDK entity expansion limit; Note that the existing system property
++ * "entityExpansionLimit" with no prefix is still observed
++ */
++ public static final String SP_ENTITY_EXPANSION_LIMIT = "jdk.xml.entityExpansionLimit";
++
++ /**
++ * JDK element attribute limit; Note that the existing system property
++ * "elementAttributeLimit" with no prefix is still observed
++ */
++ public static final String SP_ELEMENT_ATTRIBUTE_LIMIT = "jdk.xml.elementAttributeLimit";
++
++ /**
++ * JDK maxOccur limit; Note that the existing system property
++ * "maxOccurLimit" with no prefix is still observed
++ */
++ public static final String SP_MAX_OCCUR_LIMIT = "jdk.xml.maxOccurLimit";
++
++ /**
++ * JDK total entity size limit
++ */
++ public static final String SP_TOTAL_ENTITY_SIZE_LIMIT = "jdk.xml.totalEntitySizeLimit";
++
++ /**
++ * JDK maximum general entity size limit
++ */
++ public static final String SP_GENEAL_ENTITY_SIZE_LIMIT = "jdk.xml.maxGeneralEntitySizeLimit";
++ /**
++ * JDK maximum parameter entity size limit
++ */
++ public static final String SP_PARAMETER_ENTITY_SIZE_LIMIT = "jdk.xml.maxParameterEntitySizeLimit";
++ /**
++ * JDK maximum XML name limit
++ */
++ public static final String SP_XML_NAME_LIMIT = "jdk.xml.maxXMLNameLimit";
++
++ //legacy System Properties
++ public final static String ENTITY_EXPANSION_LIMIT = "entityExpansionLimit";
++ public static final String ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ;
++ public final static String MAX_OCCUR_LIMIT = "maxOccurLimit";
++
++ /**
++ * A string "yes" that can be used for properties such as getEntityCountInfo
++ */
++ public static final String JDK_YES = "yes";
++}
++
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java Tue Oct 29 08:01:29 2013 +0000
+@@ -26,6 +26,7 @@
+ import java.io.File;
+ import java.io.FileInputStream;
+ import java.io.FileNotFoundException;
++import java.io.IOException;
+ import java.io.InputStream;
+
+ import java.security.AccessController;
+@@ -36,6 +37,7 @@
+ import java.util.Locale;
+ import java.util.MissingResourceException;
+ import java.util.ResourceBundle;
++import java.util.Properties;
+
+ /**
+ * This class is duplicated for each subpackage so keep it in sync. It is
+@@ -200,6 +202,54 @@
+ })).longValue();
+ }
+
++ /**
++ * Read from $java.home/lib/jaxp.properties for the specified property
++ * The program
++ *
++ * @param propertyId the Id of the property
++ * @return the value of the property
++ */
++ static String readJAXPProperty(String propertyId) {
++ String value = null;
++ InputStream is = null;
++ try {
++ if (firstTime) {
++ synchronized (cacheProps) {
++ if (firstTime) {
++ String configFile = getSystemProperty("java.home") + File.separator +
++ "lib" + File.separator + "jaxp.properties";
++ File f = new File(configFile);
++ if (getFileExists(f)) {
++ is = getFileInputStream(f);
++ cacheProps.load(is);
++ }
++ firstTime = false;
++ }
++ }
++ }
++ value = cacheProps.getProperty(propertyId);
++
++ }
++ catch (Exception ex) {}
++ finally {
++ if (is != null) {
++ try {
++ is.close();
++ } catch (IOException ex) {}
++ }
++ }
++ return value;
++ }
++
++ /**
++ * Cache for properties in java.home/lib/jaxp.properties
++ */
++ static final Properties cacheProps = new Properties();
++
++ /**
++ * Flag indicating if the program has tried reading java.home/lib/jaxp.properties
++ */
++ static volatile boolean firstTime = true;
+
+ private SecuritySupport() {
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java Tue Oct 29 08:01:29 2013 +0000
+@@ -0,0 +1,449 @@
++/*
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
++ *
++ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
++ *
++ * The contents of this file are subject to the terms of either the GNU
++ * General Public License Version 2 only ("GPL") or the Common Development
++ * and Distribution License("CDDL") (collectively, the "License"). You
++ * may not use this file except in compliance with the License. You can
++ * obtain a copy of the License at
++ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
++ * or packager/legal/LICENSE.txt. See the License for the specific
++ * language governing permissions and limitations under the License.
++ *
++ * When distributing the software, include this License Header Notice in each
++ * file and include the License file at packager/legal/LICENSE.txt.
++ *
++ * GPL Classpath Exception:
++ * Oracle designates this particular file as subject to the "Classpath"
++ * exception as provided by Oracle in the GPL Version 2 section of the License
++ * file that accompanied this code.
++ *
++ * Modifications:
++ * If applicable, add the following below the License Header, with the fields
++ * enclosed by brackets [] replaced by your own identifying information:
++ * "Portions Copyright [year] [name of copyright owner]"
++ *
++ * Contributor(s):
++ * If you wish your version of this file to be governed by only the CDDL or
++ * only the GPL Version 2, indicate your decision by adding "[Contributor]
++ * elects to include this software in this distribution under the [CDDL or GPL
++ * Version 2] license." If you don't indicate a single choice of license, a
++ * recipient has the option to distribute your version of this file under
++ * either the CDDL, the GPL Version 2 or to extend the choice of license to
++ * its licensees as provided above. However, if you add GPL Version 2 code
++ * and therefore, elected the GPL Version 2 license, then the option applies
++ * only if the new code is made subject to such option by the copyright
++ * holder.
++ */
++package com.sun.org.apache.xalan.internal.utils;
++
++import com.sun.org.apache.xalan.internal.XalanConstants;
++
++
++/**
++ * This class is not the same as that in Xerces. It is used to manage the
++ * state of corresponding Xerces properties and pass the values over to
++ * the Xerces Security Manager.
++ *
++ * @author Joe Wang Oracle Corp.
++ *
++ */
++public final class XMLSecurityManager {
++
++ /**
++ * States of the settings of a property, in the order: default value, value
++ * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system
++ * properties, and jaxp api properties
++ */
++ public static enum State {
++ //this order reflects the overriding order
++
++ DEFAULT("default"), FSP("FEATURE_SECURE_PROCESSING"),
++ JAXPDOTPROPERTIES("jaxp.properties"), SYSTEMPROPERTY("system property"),
++ APIPROPERTY("property");
++
++ final String literal;
++ State(String literal) {
++ this.literal = literal;
++ }
++
++ String literal() {
++ return literal;
++ }
++ }
++
++ /**
++ * Limits managed by the security manager
++ */
++ public static enum Limit {
++
++ ENTITY_EXPANSION_LIMIT(XalanConstants.JDK_ENTITY_EXPANSION_LIMIT,
++ XalanConstants.SP_ENTITY_EXPANSION_LIMIT, 0, 64000),
++ MAX_OCCUR_NODE_LIMIT(XalanConstants.JDK_MAX_OCCUR_LIMIT,
++ XalanConstants.SP_MAX_OCCUR_LIMIT, 0, 5000),
++ ELEMENT_ATTRIBUTE_LIMIT(XalanConstants.JDK_ELEMENT_ATTRIBUTE_LIMIT,
++ XalanConstants.SP_ELEMENT_ATTRIBUTE_LIMIT, 0, 10000),
++ TOTAL_ENTITY_SIZE_LIMIT(XalanConstants.JDK_TOTAL_ENTITY_SIZE_LIMIT,
++ XalanConstants.SP_TOTAL_ENTITY_SIZE_LIMIT, 0, 50000000),
++ GENEAL_ENTITY_SIZE_LIMIT(XalanConstants.JDK_GENEAL_ENTITY_SIZE_LIMIT,
++ XalanConstants.SP_GENEAL_ENTITY_SIZE_LIMIT, 0, 0),
++ PARAMETER_ENTITY_SIZE_LIMIT(XalanConstants.JDK_PARAMETER_ENTITY_SIZE_LIMIT,
++ XalanConstants.SP_PARAMETER_ENTITY_SIZE_LIMIT, 0, 1000000);
++
++ final String apiProperty;
++ final String systemProperty;
++ final int defaultValue;
++ final int secureValue;
++
++ Limit(String apiProperty, String systemProperty, int value, int secureValue) {
++ this.apiProperty = apiProperty;
++ this.systemProperty = systemProperty;
++ this.defaultValue = value;
++ this.secureValue = secureValue;
++ }
++
++ public boolean equalsAPIPropertyName(String propertyName) {
++ return (propertyName == null) ? false : apiProperty.equals(propertyName);
++ }
++
++ public boolean equalsSystemPropertyName(String propertyName) {
++ return (propertyName == null) ? false : systemProperty.equals(propertyName);
++ }
++
++ public String apiProperty() {
++ return apiProperty;
++ }
++
++ String systemProperty() {
++ return systemProperty;
++ }
++
++ int defaultValue() {
++ return defaultValue;
++ }
++
++ int secureValue() {
++ return secureValue;
++ }
++ }
++
++ /**
++ * Map old property names with the new ones
++ */
++ public static enum NameMap {
++
++ ENTITY_EXPANSION_LIMIT(XalanConstants.SP_ENTITY_EXPANSION_LIMIT,
++ XalanConstants.ENTITY_EXPANSION_LIMIT),
++ MAX_OCCUR_NODE_LIMIT(XalanConstants.SP_MAX_OCCUR_LIMIT,
++ XalanConstants.MAX_OCCUR_LIMIT),
++ ELEMENT_ATTRIBUTE_LIMIT(XalanConstants.SP_ELEMENT_ATTRIBUTE_LIMIT,
++ XalanConstants.ELEMENT_ATTRIBUTE_LIMIT);
++ final String newName;
++ final String oldName;
++
++ NameMap(String newName, String oldName) {
++ this.newName = newName;
++ this.oldName = oldName;
++ }
++
++ String getOldName(String newName) {
++ if (newName.equals(this.newName)) {
++ return oldName;
++ }
++ return null;
++ }
++ }
++ /**
++ * Values of the properties
++ */
++ private final int[] values;
++ /**
++ * States of the settings for each property
++ */
++ private State[] states;
++ /**
++ * States that determine if properties are set explicitly
++ */
++ private boolean[] isSet;
++
++
++ /**
++ * Index of the special entityCountInfo property
++ */
++ private int indexEntityCountInfo = 10000;
++ private String printEntityCountInfo = "";
++
++ /**
++ * Default constructor. Establishes default values for known security
++ * vulnerabilities.
++ */
++ public XMLSecurityManager() {
++ this(false);
++ }
++
++ /**
++ * Instantiate Security Manager in accordance with the status of
++ * secure processing
++ * @param secureProcessing
++ */
++ public XMLSecurityManager(boolean secureProcessing) {
++ values = new int[Limit.values().length];
++ states = new State[Limit.values().length];
++ isSet = new boolean[Limit.values().length];
++ for (Limit limit : Limit.values()) {
++ if (secureProcessing) {
++ values[limit.ordinal()] = limit.secureValue();
++ states[limit.ordinal()] = State.FSP;
++ } else {
++ values[limit.ordinal()] = limit.defaultValue();
++ states[limit.ordinal()] = State.DEFAULT;
++ }
++ }
++ //read system properties or jaxp.properties
++ readSystemProperties();
++ }
++
++ /**
++ * Setting FEATURE_SECURE_PROCESSING explicitly
++ */
++ public void setSecureProcessing(boolean secure) {
++ for (Limit limit : Limit.values()) {
++ if (secure) {
++ setLimit(limit.ordinal(), State.FSP, limit.secureValue());
++ } else {
++ setLimit(limit.ordinal(), State.FSP, limit.defaultValue());
++ }
++ }
++ }
++
++ /**
++ * Set limit by property name and state
++ * @param propertyName property name
++ * @param state the state of the property
++ * @param value the value of the property
++ * @return true if the property is managed by the security manager; false
++ * if otherwise.
++ */
++ public boolean setLimit(String propertyName, State state, Object value) {
++ int index = getIndex(propertyName);
++ if (index > -1) {
++ setLimit(index, state, value);
++ return true;
++ }
++ return false;
++ }
++
++ /**
++ * Set the value for a specific limit.
++ *
++ * @param limit the limit
++ * @param state the state of the property
++ * @param value the value of the property
++ */
++ public void setLimit(Limit limit, State state, int value) {
++ setLimit(limit.ordinal(), state, value);
++ }
++
++ /**
++ * Set the value of a property by its index
++ *
++ * @param index the index of the property
++ * @param state the state of the property
++ * @param value the value of the property
++ */
++ public void setLimit(int index, State state, Object value) {
++ if (index == indexEntityCountInfo) {
++ //if it's explicitly set, it's treated as yes no matter the value
++ printEntityCountInfo = (String)value;
++ } else {
++ int temp = 0;
++ try {
++ temp = Integer.parseInt((String) value);
++ if (temp < 0) {
++ temp = 0;
++ }
++ } catch (NumberFormatException e) {}
++ setLimit(index, state, temp); }
++ }
++
++ /**
++ * Set the value of a property by its index
++ *
++ * @param index the index of the property
++ * @param state the state of the property
++ * @param value the value of the property
++ */
++ public void setLimit(int index, State state, int value) {
++ if (index == indexEntityCountInfo) {
++ //if it's explicitly set, it's treated as yes no matter the value
++ printEntityCountInfo = XalanConstants.JDK_YES;
++ } else {
++ //only update if it shall override
++ if (state.compareTo(states[index]) >= 0) {
++ values[index] = value;
++ states[index] = state;
++ isSet[index] = true;
++ }
++ }
++ }
++
++
++ /**
++ * Return the value of the specified property.
++ *
++ * @param propertyName the property name
++ * @return the value of the property as a string. If a property is managed
++ * by this manager, its value shall not be null.
++ */
++ public String getLimitAsString(String propertyName) {
++ int index = getIndex(propertyName);
++ if (index > -1) {
++ return getLimitValueByIndex(index);
++ }
++
++ return null;
++ }
++
++ /**
++ * Return the value of a property by its ordinal
++ *
++ * @param limit the property
++ * @return value of a property
++ */
++ public String getLimitValueAsString(Limit limit) {
++ return Integer.toString(values[limit.ordinal()]);
++ }
++
++ /**
++ * Return the value of the specified property
++ *
++ * @param limit the property
++ * @return the value of the property
++ */
++ public int getLimit(Limit limit) {
++ return values[limit.ordinal()];
++ }
++
++ /**
++ * Return the value of a property by its ordinal
++ *
++ * @param index the index of a property
++ * @return value of a property
++ */
++ public int getLimitByIndex(int index) {
++ return values[index];
++ }
++ /**
++ * Return the value of a property by its index
++ *
++ * @param index the index of a property
++ * @return limit of a property as a string
++ */
++ public String getLimitValueByIndex(int index) {
++ if (index == indexEntityCountInfo) {
++ return printEntityCountInfo;
++ }
++
++ return Integer.toString(values[index]);
++ }
++ /**
++ * Return the state of the limit property
++ *
++ * @param limit the limit
++ * @return the state of the limit property
++ */
++ public State getState(Limit limit) {
++ return states[limit.ordinal()];
++ }
++
++ /**
++ * Return the state of the limit property
++ *
++ * @param limit the limit
++ * @return the state of the limit property
++ */
++ public String getStateLiteral(Limit limit) {
++ return states[limit.ordinal()].literal();
++ }
++
++ /**
++ * Get the index by property name
++ *
++ * @param propertyName property name
++ * @return the index of the property if found; return -1 if not
++ */
++ public int getIndex(String propertyName) {
++ for (Limit limit : Limit.values()) {
++ if (limit.equalsAPIPropertyName(propertyName)) {
++ //internally, ordinal is used as index
++ return limit.ordinal();
++ }
++ }
++ //special property to return entity count info
++ if (propertyName.equals(XalanConstants.JDK_ENTITY_COUNT_INFO)) {
++ return indexEntityCountInfo;
++ }
++ return -1;
++ }
++
++ /**
++ * Indicate if a property is set explicitly
++ * @param index
++ * @return
++ */
++ public boolean isSet(int index) {
++ return isSet[index];
++ }
++
++ public boolean printEntityCountInfo() {
++ return printEntityCountInfo.equals(XalanConstants.JDK_YES);
++ }
++ /**
++ * Read from system properties, or those in jaxp.properties
++ */
++ private void readSystemProperties() {
++
++ for (Limit limit : Limit.values()) {
++ if (!getSystemProperty(limit, limit.systemProperty())) {
++ //if system property is not found, try the older form if any
++ for (NameMap nameMap : NameMap.values()) {
++ String oldName = nameMap.getOldName(limit.systemProperty());
++ if (oldName != null) {
++ getSystemProperty(limit, oldName);
++ }
++ }
++ }
++ }
++
++ }
++
++ /**
++ * Read from system properties, or those in jaxp.properties
++ *
++ * @param property the type of the property
++ * @param sysPropertyName the name of system property
++ */
++ private boolean getSystemProperty(Limit limit, String sysPropertyName) {
++ try {
++ String value = SecuritySupport.getSystemProperty(sysPropertyName);
++ if (value != null && !value.equals("")) {
++ values[limit.ordinal()] = Integer.parseInt(value);
++ states[limit.ordinal()] = State.SYSTEMPROPERTY;
++ return true;
++ }
++
++ value = SecuritySupport.readJAXPProperty(sysPropertyName);
++ if (value != null && !value.equals("")) {
++ values[limit.ordinal()] = Integer.parseInt(value);
++ states[limit.ordinal()] = State.JAXPDOTPROPERTIES;
++ return true;
++ }
++ } catch (NumberFormatException e) {
++ //invalid setting
++ throw new NumberFormatException("Invalid setting for system property: " + limit.systemProperty());
++ }
++ return false;
++ }
++}
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/Parser.java Tue Oct 29 08:01:29 2013 +0000
+@@ -40,10 +40,12 @@
+ import javax.xml.parsers.SAXParser;
+ import javax.xml.parsers.SAXParserFactory;
+
++import com.sun.org.apache.xalan.internal.XalanConstants;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
++import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
+ import org.xml.sax.Attributes;
+ import org.xml.sax.helpers.AttributesImpl;
+ import org.xml.sax.ContentHandler;
+@@ -466,6 +468,20 @@
+ }
+ final SAXParser parser = factory.newSAXParser();
+ final XMLReader reader = parser.getXMLReader();
++ try {
++ XMLSecurityManager securityManager =
++ (XMLSecurityManager)_xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
++ for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
++ reader.setProperty(limit.apiProperty(), securityManager.getLimitValueAsString(limit));
++ }
++ if (securityManager.printEntityCountInfo()) {
++ parser.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
++ }
++ } catch (SAXException se) {
++ System.err.println("Warning: " + reader.getClass().getName() + ": "
++ + se.getMessage());
++ }
++
+ return(parse(reader, input));
+ }
+ catch (ParserConfigurationException e) {
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java Tue Oct 29 08:01:29 2013 +0000
+@@ -41,12 +41,13 @@
+ import java.util.jar.Manifest;
+
+ import com.sun.org.apache.bcel.internal.classfile.JavaClass;
++import com.sun.org.apache.xalan.internal.XalanConstants;
+ import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
++import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
+ import com.sun.org.apache.xml.internal.dtm.DTM;
+
+-import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+ import org.xml.sax.InputSource;
+ import org.xml.sax.XMLReader;
+
+@@ -105,6 +106,7 @@
+ public static final int BYTEARRAY_AND_FILE_OUTPUT = 4;
+ public static final int BYTEARRAY_AND_JAR_OUTPUT = 5;
+
++ private XMLSecurityManager _xmlSecurityManager;
+
+ // Compiler options (passed from command line or XSLTC client)
+ private boolean _debug = false; // -x
+@@ -898,4 +900,24 @@
+
+ return newDataOffset;
+ }
++
++ /**
++ * Return allowed protocols for accessing external stylesheet.
++ */
++ public Object getProperty(String name) {
++ if (name.equals(XalanConstants.SECURITY_MANAGER)) {
++ return _xmlSecurityManager;
++ }
++ return null;
++ }
++
++ /**
++ * Set allowed protocols for accessing external stylesheet.
++ */
++ public void setProperty(String name, Object value) {
++ if (name.equals(XalanConstants.SECURITY_MANAGER)) {
++ _xmlSecurityManager = (XMLSecurityManager)value;
++ }
++ }
++
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -29,7 +29,7 @@
+ import javax.xml.transform.TransformerException;
+ import javax.xml.transform.URIResolver;
+ import javax.xml.transform.sax.TemplatesHandler;
+-
++import com.sun.org.apache.xalan.internal.XalanConstants;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.CompilerException;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.Parser;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
+@@ -98,6 +98,8 @@
+ XSLTC xsltc = new XSLTC();
+ if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING))
+ xsltc.setSecureProcessing(true);
++ xsltc.setProperty(XalanConstants.SECURITY_MANAGER,
++ tfactory.getAttribute(XalanConstants.SECURITY_MANAGER));
+
+ _parser = xsltc.getParser();
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -64,12 +64,14 @@
+ import com.sun.org.apache.xml.internal.utils.StylesheetPIHandler;
+ import com.sun.org.apache.xml.internal.utils.StopParseException;
+
++import com.sun.org.apache.xalan.internal.XalanConstants;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
+ import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
+ import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
++import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
+
+ import org.xml.sax.InputSource;
+ import org.xml.sax.XMLFilter;
+@@ -221,8 +223,13 @@
+ _isSecureMode = true;
+ _isNotSecureProcessing = false;
+ }
++
++ //Parser's security manager
++ _xmlSecurityManager = new XMLSecurityManager(true);
+ }
+
++ private XMLSecurityManager _xmlSecurityManager;
++
+ /**
+ * javax.xml.transform.sax.TransformerFactory implementation.
+ * Set the error event listener for the TransformerFactory, which is used
+@@ -273,8 +280,9 @@
+ }
+ else if (name.equals(AUTO_TRANSLET)) {
+ return new Boolean(_autoTranslet);
++ } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
++ return _xmlSecurityManager;
+ }
+-
+ // Throw an exception for all other attributes
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
+ throw new IllegalArgumentException(err.toString());
+@@ -417,6 +425,7 @@
+ throw new TransformerConfigurationException(err.toString());
+ }
+ _isNotSecureProcessing = !value;
++ _xmlSecurityManager.setSecureProcessing(value);
+ // all done processing feature
+ return;
+ }
+@@ -757,6 +766,7 @@
+ if (_debug) xsltc.setDebug(true);
+ if (_enableInlining) xsltc.setTemplateInlining(true);
+ if (!_isNotSecureProcessing) xsltc.setSecureProcessing(true);
++ xsltc.setProperty(XalanConstants.SECURITY_MANAGER, _xmlSecurityManager);
+ xsltc.init();
+
+ // Set a document loader (for xsl:include/import) if defined
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -64,6 +64,8 @@
+
+ import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
+
++import com.sun.org.apache.xalan.internal.XalanConstants;
++import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xalan.internal.xsltc.DOM;
+ import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
+ import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
+@@ -208,6 +210,7 @@
+ */
+ private Hashtable _parameters = null;
+
++ private XMLSecurityManager _securityManager;
+ /**
+ * This class wraps an ErrorListener into a MessageHandler in order to
+ * capture messages reported via xsl:message.
+@@ -252,7 +255,9 @@
+ _propertiesClone = (Properties) _properties.clone();
+ _indentNumber = indentNumber;
+ _tfactory = tfactory;
++ _securityManager = (XMLSecurityManager)_tfactory.getAttribute(XalanConstants.SECURITY_MANAGER);
+ _readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
++ _readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
+ //_isIncremental = tfactory._incremental;
+ }
+
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/Util.java Tue Oct 29 08:01:29 2013 +0000
+@@ -23,6 +23,7 @@
+
+ package com.sun.org.apache.xalan.internal.xsltc.trax;
+
++import com.sun.org.apache.xalan.internal.XalanConstants;
+ import java.io.InputStream;
+ import java.io.Reader;
+
+@@ -42,6 +43,7 @@
+ import javax.xml.transform.stax.StAXSource;
+ import javax.xml.transform.stream.StreamSource;
+
++import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC;
+ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
+
+@@ -143,6 +145,22 @@
+ reader.setFeature
+ ("http://xml.org/sax/features/namespace-prefixes",false);
+
++ try {
++ XMLSecurityManager securityManager =
++ (XMLSecurityManager)xsltc.getProperty(XalanConstants.SECURITY_MANAGER);
++ if (securityManager != null) {
++ for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
++ reader.setProperty(limit.apiProperty(),
++ securityManager.getLimitValueAsString(limit));
++ }
++ if (securityManager.printEntityCountInfo()) {
++ reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
++ }
++ }
++ } catch (SAXException se) {
++ System.err.println("Warning: " + reader.getClass().getName() + ": "
++ + se.getMessage());
++ }
+ xsltc.setXMLReader(reader);
+ }catch (SAXNotRecognizedException snre ) {
+ throw new TransformerConfigurationException
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -53,6 +53,7 @@
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import org.w3c.dom.DOMException;
+ import org.w3c.dom.ls.LSResourceResolver;
+
+@@ -189,6 +190,9 @@
+ private DOMStringList fRecognizedParameters;
+
+
++ /** Property identifier: Security manager. */
++ private static final String SECURITY_MANAGER = Constants.SECURITY_MANAGER;
++
+ //
+ // Constructors
+ //
+@@ -259,7 +263,8 @@
+ GRAMMAR_POOL,
+ JAXP_SCHEMA_SOURCE,
+ JAXP_SCHEMA_LANGUAGE,
+- DTD_VALIDATOR_FACTORY_PROPERTY
++ DTD_VALIDATOR_FACTORY_PROPERTY,
++ SECURITY_MANAGER,
+ };
+ addRecognizedProperties(recognizedProperties);
+
+@@ -293,6 +298,8 @@
+ fValidationManager = createValidationManager();
+ setProperty(VALIDATION_MANAGER, fValidationManager);
+
++ setProperty(SECURITY_MANAGER, new XMLSecurityManager(true));
++
+
+ // add message formatters
+ if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/Constants.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/Constants.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/Constants.java Tue Oct 29 08:01:29 2013 +0000
+@@ -156,9 +156,111 @@
+ /** JAXP schemaSource language: when used internally may include DTD namespace (DOM) */
+ public static final String SCHEMA_LANGUAGE = "schemaLanguage";
+
+- public static final String SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ;
++ /** Oracle JAXP property prefix ("http://www.oracle.com/xml/jaxp/properties/"). */
++ public static final String ORACLE_JAXP_PROPERTY_PREFIX =
++ "http://www.oracle.com/xml/jaxp/properties/";
+
+ //
++ // Implementation limits: corresponding System Properties of the above
++ // API properties
++ //
++ /**
++ * JDK entity expansion limit; Note that the existing system property
++ * "entityExpansionLimit" with no prefix is still observed
++ */
++ public static final String JDK_ENTITY_EXPANSION_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "entityExpansionLimit";
++
++ /**
++ * JDK element attribute limit; Note that the existing system property
++ * "elementAttributeLimit" with no prefix is still observed
++ */
++ public static final String JDK_ELEMENT_ATTRIBUTE_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "elementAttributeLimit";
++
++ /**
++ * JDK maxOccur limit; Note that the existing system property
++ * "maxOccurLimit" with no prefix is still observed
++ */
++ public static final String JDK_MAX_OCCUR_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "maxOccurLimit";
++
++ /**
++ * JDK total entity size limit
++ */
++ public static final String JDK_TOTAL_ENTITY_SIZE_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "totalEntitySizeLimit";
++
++ /**
++ * JDK maximum general entity size limit
++ */
++ public static final String JDK_GENEAL_ENTITY_SIZE_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "maxGeneralEntitySizeLimit";
++ /**
++ * JDK maximum parameter entity size limit
++ */
++ public static final String JDK_PARAMETER_ENTITY_SIZE_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "maxParameterEntitySizeLimit";
++ /**
++ * JDK maximum XML name limit
++ */
++ public static final String JDK_XML_NAME_LIMIT =
++ ORACLE_JAXP_PROPERTY_PREFIX + "maxXMLNameLimit";
++ /**
++ * JDK property to allow printing out information from the limit analyzer
++ */
++ public static final String JDK_ENTITY_COUNT_INFO =
++ ORACLE_JAXP_PROPERTY_PREFIX + "getEntityCountInfo";
++
++ //
++ // Implementation limits: API properties
++ //
++ /**
++ * JDK entity expansion limit; Note that the existing system property
++ * "entityExpansionLimit" with no prefix is still observed
++ */
++ public static final String SP_ENTITY_EXPANSION_LIMIT = "jdk.xml.entityExpansionLimit";
++
++ /**
++ * JDK element attribute limit; Note that the existing system property
++ * "elementAttributeLimit" with no prefix is still observed
++ */
++ public static final String SP_ELEMENT_ATTRIBUTE_LIMIT = "jdk.xml.elementAttributeLimit";
++
++ /**
++ * JDK maxOccur limit; Note that the existing system property
++ * "maxOccurLimit" with no prefix is still observed
++ */
++ public static final String SP_MAX_OCCUR_LIMIT = "jdk.xml.maxOccurLimit";
++
++ /**
++ * JDK total entity size limit
++ */
++ public static final String SP_TOTAL_ENTITY_SIZE_LIMIT = "jdk.xml.totalEntitySizeLimit";
++
++ /**
++ * JDK maximum general entity size limit
++ */
++ public static final String SP_GENEAL_ENTITY_SIZE_LIMIT = "jdk.xml.maxGeneralEntitySizeLimit";
++ /**
++ * JDK maximum parameter entity size limit
++ */
++ public static final String SP_PARAMETER_ENTITY_SIZE_LIMIT = "jdk.xml.maxParameterEntitySizeLimit";
++ /**
++ * JDK maximum XML name limit
++ */
++ public static final String SP_XML_NAME_LIMIT = "jdk.xml.maxXMLNameLimit";
++
++ //legacy System Properties
++ public final static String ENTITY_EXPANSION_LIMIT = "entityExpansionLimit";
++ public static final String ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ;
++ public final static String MAX_OCCUR_LIMIT = "maxOccurLimit";
++
++ /**
++ * A string "yes" that can be used for properties such as getEntityCountInfo
++ */
++ public static final String JDK_YES = "yes";
++ //
+ // DOM features
+ //
+
+@@ -387,7 +489,7 @@
+ public static final String LOCALE_PROPERTY = "locale";
+
+ /** property identifier: security manager. */
+- protected static final String SECURITY_MANAGER =
++ public static final String SECURITY_MANAGER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
+
+
+@@ -452,9 +554,6 @@
+ */
+ public final static String ATTRIBUTE_DECLARED = "ATTRIBUTE_DECLARED";
+
+- public final static String ENTITY_EXPANSION_LIMIT = "entityExpansionLimit";
+-
+- public final static String MAX_OCCUR_LIMIT = "maxOccurLimit";
+
+ /**
+ * {@link org.w3c.dom.TypeInfo} associated with current element/attribute
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Oct 29 08:01:29 2013 +0000
+@@ -25,6 +25,7 @@
+
+ package com.sun.org.apache.xerces.internal.impl;
+
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import java.util.HashMap;
+ import javax.xml.stream.XMLInputFactory;
+ import javax.xml.stream.XMLOutputFactory;
+@@ -50,9 +51,13 @@
+
+ private static final String STRING_INTERNING = "http://xml.org/sax/features/string-interning";
+
++ /** Property identifier: Security manager. */
++ private static final String SECURITY_MANAGER = Constants.SECURITY_MANAGER;
+
+ HashMap supportedProps = new HashMap();
+
++ private XMLSecurityManager fSecurityManager;
++
+ public static final int CONTEXT_READER = 1;
+ public static final int CONTEXT_WRITER = 2;
+
+@@ -77,6 +82,7 @@
+
+ HashMap properties = propertyManager.getProperties();
+ supportedProps.putAll(properties);
++ fSecurityManager = (XMLSecurityManager)getProperty(SECURITY_MANAGER);
+ }
+
+ private HashMap getProperties(){
+@@ -117,6 +123,9 @@
+ supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE, new Boolean(false));
+ supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ENTITYDEF_FEATURE, new Boolean(false));
+ supportedProps.put(Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_UNDECLARED_ELEMDEF_FEATURE, new Boolean(false));
++
++ fSecurityManager = new XMLSecurityManager(true);
++ supportedProps.put(SECURITY_MANAGER, fSecurityManager);
+ }
+
+ private void initWriterProps(){
+@@ -132,7 +141,8 @@
+ * }
+ */
+ public boolean containsProperty(String property){
+- return supportedProps.containsKey(property) ;
++ return supportedProps.containsKey(property) ||
++ (fSecurityManager != null && fSecurityManager.getIndex(property) > -1) ;
+ }
+
+ public Object getProperty(String property){
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -108,6 +108,7 @@
+ * @author Elena Litani, IBM
+ * @author Michael Glavassevich, IBM
+ * @author Sunitha Reddy, Sun Microsystems
++ * @version $Id: XML11NSDocumentScannerImpl.java,v 1.6 2010-11-01 04:39:40 joehw Exp $
+ */
+ public class XML11NSDocumentScannerImpl extends XML11DocumentScannerImpl {
+
+@@ -236,7 +237,8 @@
+
+ // attributes
+ scanAttribute(fAttributes);
+- if (fSecurityManager != null && fAttributes.getLength() > fElementAttributeLimit){
++ if (fSecurityManager != null && (!fSecurityManager.isNoLimit(fElementAttributeLimit)) &&
++ fAttributes.getLength() > fElementAttributeLimit){
+ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
+ "ElementAttributeLimit",
+ new Object[]{rawname, new Integer(fElementAttributeLimit) },
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -44,6 +44,8 @@
+ import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
+ import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
+ import com.sun.org.apache.xerces.internal.impl.Constants;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
++import com.sun.xml.internal.stream.Entity;
+
+ /**
+ * This class is responsible for scanning the declarations found
+@@ -66,7 +68,7 @@
+ * @author Glenn Marcy, IBM
+ * @author Eric Ye, IBM
+ *
+- * @version $Id: XMLDTDScannerImpl.java,v 1.7 2007/09/26 12:52:40 ndw Exp $
++ * @version $Id: XMLDTDScannerImpl.java,v 1.8 2010-11-01 04:39:41 joehw Exp $
+ */
+ public class XMLDTDScannerImpl
+ extends XMLScanner
+@@ -1545,7 +1547,7 @@
+
+ // internal entity
+ if (systemId == null) {
+- scanEntityValue(fLiteral, fLiteral2);
++ scanEntityValue(name, isPEDecl, fLiteral, fLiteral2);
+ // since we need it's value anyway, let's snag it so it doesn't get corrupted
+ // if a new load takes place before we store the entity values
+ fStringBuffer.clear();
+@@ -1610,7 +1612,7 @@
+ * the use of scanCharReferenceValue), and fStringBuffer2, anything in them
+ * at the time of calling is lost.
+ */
+- protected final void scanEntityValue(XMLString value,
++ protected final void scanEntityValue(String entityName, boolean isPEDecl, XMLString value,
+ XMLString nonNormalizedValue)
+ throws IOException, XNIException {
+ int quote = fEntityScanner.scanChar();
+@@ -1622,10 +1624,20 @@
+
+ XMLString literal = fString;
+ XMLString literal2 = fString;
++ int countChar = 0;
++ if (fLimitAnalyzer == null && fSecurityManager != null) {
++ fLimitAnalyzer = fSecurityManager.getLimitAnalyzer();
++ fLimitAnalyzer.startEntity(entityName);
++ }
++
+ if (fEntityScanner.scanLiteral(quote, fString) != quote) {
+ fStringBuffer.clear();
+ fStringBuffer2.clear();
+ do {
++ if (isPEDecl && fLimitAnalyzer != null) {
++ checkLimit("%" + entityName, fString.length + countChar);
++ }
++ countChar = 0;
+ fStringBuffer.append(fString);
+ fStringBuffer2.append(fString);
+ if (fEntityScanner.skipChar('&')) {
+@@ -1685,6 +1697,7 @@
+ }
+ }
+ else {
++ countChar++;
+ int c = fEntityScanner.peekChar();
+ if (XMLChar.isHighSurrogate(c)) {
+ scanSurrogates(fStringBuffer2);
+@@ -1708,9 +1721,17 @@
+ fStringBuffer2.append(fString);
+ literal = fStringBuffer;
+ literal2 = fStringBuffer2;
++ } else {
++ if (isPEDecl) {
++ checkLimit("%" + entityName, literal);
++ }
+ }
+ value.setValues(literal);
+ nonNormalizedValue.setValues(literal2);
++ if (fLimitAnalyzer != null) {
++ fLimitAnalyzer.endEntity(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, entityName);
++ }
++
+ if (!fEntityScanner.skipChar(quote)) {
+ reportFatalError("CloseQuoteMissingInDecl", null);
+ }
+@@ -2126,6 +2147,43 @@
+ //new SymbolTable());
+ }
+
++ /**
++ * Add the count of the content buffer and check if the accumulated
++ * value exceeds the limit
++ * @param entityName entity name
++ * @param buffer content buffer
++ */
++ private void checkLimit(String entityName, XMLString buffer) {
++ checkLimit(entityName, buffer.length);
++ }
++
++ /**
++ * Add the count and check limit
++ * @param entityName entity name
++ * @param len length of the buffer
++ */
++ private void checkLimit(String entityName, int len) {
++ if (fLimitAnalyzer == null) {
++ fLimitAnalyzer = fSecurityManager.getLimitAnalyzer();
++ }
++ fLimitAnalyzer.addValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, entityName, len);
++ if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT)) {
++ fSecurityManager.debugPrint();
++ reportFatalError("MaxEntitySizeLimit", new Object[]{entityName,
++ fLimitAnalyzer.getValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
++ fSecurityManager.getLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
++ fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT)});
++ }
++ if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT)) {
++ fSecurityManager.debugPrint();
++ reportFatalError("TotalEntitySizeLimit",
++ new Object[]{fLimitAnalyzer.getTotalValue(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
++ fSecurityManager.getLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT),
++ fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT)});
++ }
++
++ }
++
+ public DTDGrammar getGrammar(){
+ return nvGrammarInfo;
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -18,7 +18,6 @@
+ * limitations under the License.
+ */
+
+-
+ package com.sun.org.apache.xerces.internal.impl;
+
+ import com.sun.xml.internal.stream.XMLBufferListener;
+@@ -51,7 +50,10 @@
+ import com.sun.org.apache.xerces.internal.impl.Constants;
+ import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
+ import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
++import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
+ import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.State;
+ import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+ import javax.xml.stream.XMLStreamConstants;
+ import javax.xml.stream.events.XMLEvent;
+@@ -194,7 +196,7 @@
+ };
+
+ protected static final char [] cdata = {'[','C','D','A','T','A','['};
+- protected static final char [] xmlDecl = {'<','?','x','m','l'};
++ static final char [] xmlDecl = {'<','?','x','m','l'};
+ protected static final char [] endTag = {'<','/'};
+ // debugging
+
+@@ -350,7 +352,6 @@
+
+ protected boolean foundBuiltInRefs = false;
+
+- protected XMLSecurityManager fSecurityManager = null;
+
+ //skip element algorithm
+ static final short MAX_DEPTH_LIMIT = 5 ;
+@@ -559,6 +560,8 @@
+ } catch (XMLConfigurationException e) {
+ fSecurityManager = null;
+ }
++ fLimitAnalyzer = fSecurityManager.getLimitAnalyzer();
++
+ fElementAttributeLimit = (fSecurityManager != null)?
+ fSecurityManager.getLimit(XMLSecurityManager.Limit.ELEMENT_ATTRIBUTE_LIMIT):0;
+
+@@ -604,8 +607,7 @@
+ fEntityStore = fEntityManager.getEntityStore();
+
+ dtdGrammarUtil = null;
+-
+-
++
+ //fEntityManager.test();
+ } // reset(XMLComponentManager)
+
+@@ -655,6 +657,8 @@
+
+ dtdGrammarUtil = null;
+
++ fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(Constants.SECURITY_MANAGER);
++ fLimitAnalyzer = fSecurityManager.getLimitAnalyzer();
+ } // reset(XMLComponentManager)
+
+ /**
+@@ -931,7 +935,6 @@
+
+ // scan decl
+ super.scanXMLDeclOrTextDecl(scanningTextDecl, fStrings);
+-
+ fMarkupDepth--;
+
+ // pseudo-attribute values
+@@ -1298,7 +1301,8 @@
+ fAddDefaultAttr = true;
+ do {
+ scanAttribute(fAttributes);
+- if (fSecurityManager != null && fAttributes.getLength() > fElementAttributeLimit){
++ if (fSecurityManager != null && !fSecurityManager.isNoLimit(fElementAttributeLimit) &&
++ fAttributes.getLength() > fElementAttributeLimit){
+ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
+ "ElementAttributeLimit",
+ new Object[]{rawname, new Integer(fAttributes.getLength()) },
+@@ -2800,6 +2804,8 @@
+ if(DEBUG){
+ System.out.println("NOT USING THE BUFFER, STRING = " + fTempString.toString());
+ }
++ //check limit before returning event
++ checkLimit(fContentBuffer);
+ if(dtdGrammarUtil!= null && dtdGrammarUtil.isIgnorableWhiteSpace(fContentBuffer)){
+ if(DEBUG)System.out.println("Return SPACE EVENT");
+ return XMLEvent.SPACE;
+@@ -2898,6 +2904,8 @@
+ fLastSectionWasCharacterData = true ;
+ return fDriver.next();
+ }else{
++ //check limit before returning event
++ checkLimit(fContentBuffer);
+ if(dtdGrammarUtil!= null && dtdGrammarUtil.isIgnorableWhiteSpace(fContentBuffer)){
+ if(DEBUG)System.out.println("Return SPACE EVENT");
+ return XMLEvent.SPACE;
+@@ -3108,6 +3116,31 @@
+
+ }//next
+
++
++ /**
++ * Add the count of the content buffer and check if the accumulated
++ * value exceeds the limit
++ * @param buffer content buffer
++ */
++ protected void checkLimit(XMLStringBuffer buffer) {
++ if (fLimitAnalyzer.isTracking(fCurrentEntityName)) {
++ fLimitAnalyzer.addValue(Limit.GENEAL_ENTITY_SIZE_LIMIT, fCurrentEntityName, buffer.length);
++ if (fSecurityManager.isOverLimit(Limit.GENEAL_ENTITY_SIZE_LIMIT)) {
++ fSecurityManager.debugPrint();
++ reportFatalError("MaxEntitySizeLimit", new Object[]{fCurrentEntityName,
++ fLimitAnalyzer.getValue(Limit.GENEAL_ENTITY_SIZE_LIMIT),
++ fSecurityManager.getLimit(Limit.GENEAL_ENTITY_SIZE_LIMIT),
++ fSecurityManager.getStateLiteral(Limit.GENEAL_ENTITY_SIZE_LIMIT)});
++ }
++ if (fSecurityManager.isOverLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT)) {
++ fSecurityManager.debugPrint();
++ reportFatalError("TotalEntitySizeLimit",
++ new Object[]{fLimitAnalyzer.getTotalValue(Limit.TOTAL_ENTITY_SIZE_LIMIT),
++ fSecurityManager.getLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT),
++ fSecurityManager.getStateLiteral(Limit.TOTAL_ENTITY_SIZE_LIMIT)});
++ }
++ }
++ }
+
+ //
+ // Protected methods
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Tue Oct 29 08:01:29 2013 +0000
+@@ -18,7 +18,7 @@
+ * limitations under the License.
+ */
+
+-package com.sun.org.apache.xerces.internal.impl ;
++package com.sun.org.apache.xerces.internal.impl;
+
+ import com.sun.xml.internal.stream.StaxEntityResolverWrapper;
+ import com.sun.xml.internal.stream.StaxXMLInputSource;
+@@ -65,6 +65,7 @@
+
+ import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
+ import com.sun.org.apache.xerces.internal.util.URI;
++import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
+ import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+
+
+@@ -319,10 +320,13 @@
+ */
+ protected int fBufferSize = DEFAULT_BUFFER_SIZE;
+
+- // stores defaults for entity expansion limit if it has
+- // been set on the configuration.
++ /** Security Manager */
+ protected XMLSecurityManager fSecurityManager = null;
+
++ protected XMLLimitAnalyzer fLimitAnalyzer = null;
++
++ protected int entityExpansionIndex;
++
+ /**
+ * True if the document entity is standalone. This should really
+ * only be set by the document source (e.g. XMLDocumentScanner).
+@@ -347,10 +351,6 @@
+ /** XML 1.1 entity scanner. */
+ protected XMLEntityScanner fXML11EntityScanner;
+
+- /** entity expansion limit (contains useful data if and only if
+- fSecurityManager is non-null) */
+- protected int fEntityExpansionLimit = 0;
+-
+ /** count of entities expanded: */
+ protected int fEntityExpansionCount = 0;
+
+@@ -848,6 +848,9 @@
+ fCurrentEntity.setEncodingExternallySpecified(encodingExternallySpecified);
+ fEntityScanner.setCurrentEntity(fCurrentEntity);
+ fResourceIdentifier.setValues(publicId, literalSystemId, baseSystemId, expandedSystemId);
++ if (fLimitAnalyzer != null) {
++ fLimitAnalyzer.startEntity(name);
++ }
+ return encoding;
+ } //setupCurrentEntity(String, XMLInputSource, boolean, boolean): String
+
+@@ -1297,10 +1300,13 @@
+ //expansions exceeds the entity expansion limit, parser will throw fatal error.
+ // Note that this represents the nesting level of open entities.
+ fEntityExpansionCount++;
+- if( fSecurityManager != null && fEntityExpansionCount > fEntityExpansionLimit ){
+- fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
+- "EntityExpansionLimitExceeded",
+- new Object[]{new Integer(fEntityExpansionLimit) },
++ if(fLimitAnalyzer != null) {
++ fLimitAnalyzer.addValue(entityExpansionIndex, name, 1);
++ }
++ if( fSecurityManager != null && fSecurityManager.isOverLimit(entityExpansionIndex)){
++ fSecurityManager.debugPrint();
++ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,"EntityExpansionLimitExceeded",
++ new Object[]{fSecurityManager.getLimitValueByIndex(entityExpansionIndex)},
+ XMLErrorReporter.SEVERITY_FATAL_ERROR );
+ // is there anything better to do than reset the counter?
+ // at least one can envision debugging applications where this might
+@@ -1381,6 +1387,12 @@
+ if(fCurrentEntity != null){
+ //close the reader
+ try{
++ if (fLimitAnalyzer != null) {
++ fLimitAnalyzer.endEntity(XMLSecurityManager.Limit.GENEAL_ENTITY_SIZE_LIMIT, fCurrentEntity.name);
++ if (fCurrentEntity.name.equals("[xml]")) {
++ fSecurityManager.debugPrint();
++ }
++ }
+ fCurrentEntity.close();
+ }catch(IOException ex){
+ throw new XNIException(ex);
+@@ -1425,6 +1437,9 @@
+ fStaxEntityResolver = null;
+ }
+
++ fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(SECURITY_MANAGER);
++ fLimitAnalyzer = fSecurityManager.getLimitAnalyzer();
++
+ // initialize state
+ //fStandalone = false;
+ fEntities.clear();
+@@ -1536,6 +1551,8 @@
+ catch (XMLConfigurationException e) {
+ fSecurityManager = null;
+ }
++ fLimitAnalyzer = fSecurityManager.getLimitAnalyzer();
++ entityExpansionIndex = fSecurityManager.getIndex(Constants.JDK_ENTITY_EXPANSION_LIMIT);
+
+ //reset general state
+ reset();
+@@ -1549,9 +1566,6 @@
+ // a class acting as a component manager but not
+ // implementing that interface for whatever reason.
+ public void reset() {
+- fEntityExpansionLimit = (fSecurityManager != null)?
+- fSecurityManager.getLimit(XMLSecurityManager.Limit.ENTITY_EXPANSION_LIMIT):0;
+-
+
+ // initialize state
+ fStandalone = false;
+@@ -1692,8 +1706,7 @@
+ if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
+ propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
+ fSecurityManager = (XMLSecurityManager)value;
+- fEntityExpansionLimit = (fSecurityManager != null)?
+- fSecurityManager.getLimit(XMLSecurityManager.Limit.ENTITY_EXPANSION_LIMIT):0;
++ fLimitAnalyzer = fSecurityManager.getLimitAnalyzer();
+ }
+ }
+
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -58,6 +58,7 @@
+ * @author Neeraj Bajaj, Sun Microsystems
+ * @author Venugopal Rao K, Sun Microsystems
+ * @author Elena Litani, IBM
++ * @version $Id: XMLNSDocumentScannerImpl.java,v 1.11 2010-11-01 04:39:41 joehw Exp $
+ */
+ public class XMLNSDocumentScannerImpl
+ extends XMLDocumentScannerImpl {
+@@ -251,7 +252,8 @@
+
+ do {
+ scanAttribute(fAttributes);
+- if (fSecurityManager != null && fAttributes.getLength() > fElementAttributeLimit){
++ if (fSecurityManager != null && (!fSecurityManager.isNoLimit(fElementAttributeLimit)) &&
++ fAttributes.getLength() > fElementAttributeLimit){
+ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
+ "ElementAttributeLimit",
+ new Object[]{rawname, new Integer(fAttributes.getLength()) },
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Tue Oct 29 08:01:29 2013 +0000
+@@ -31,6 +31,8 @@
+ import com.sun.org.apache.xerces.internal.util.XMLChar;
+ import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl;
+ import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
++import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.Augmentations;
+ import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
+ import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
+@@ -105,6 +107,9 @@
+ protected static final String ENTITY_MANAGER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
+
++ /** Property identifier: Security manager. */
++ private static final String SECURITY_MANAGER = Constants.SECURITY_MANAGER;
++
+ // debugging
+
+ /** Debug attribute normalization. */
+@@ -158,6 +163,12 @@
+ /** xxx this should be available from EntityManager Entity storage */
+ protected XMLEntityStorage fEntityStore = null ;
+
++ /** Security manager. */
++ protected XMLSecurityManager fSecurityManager = null;
++
++ /** Limit analyzer. */
++ protected XMLLimitAnalyzer fLimitAnalyzer = null;
++
+ // protected data
+
+ /** event type */
+@@ -259,6 +270,7 @@
+ fSymbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);
+ fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
+ fEntityManager = (XMLEntityManager)componentManager.getProperty(ENTITY_MANAGER);
++ fSecurityManager = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER);
+
+ //this step is extra because we have separated the storage of entity
+ fEntityStore = fEntityManager.getEntityStore() ;
+@@ -309,6 +321,10 @@
+ fEntityManager = (XMLEntityManager)value;
+ }
+ }
++
++ if (propertyId.equals(SECURITY_MANAGER)) {
++ fSecurityManager = (XMLSecurityManager)value;
++ }
+ /*else if(propertyId.equals(Constants.STAX_PROPERTIES)){
+ fStaxProperties = (HashMap)value;
+ //TODO::discuss with neeraj what are his thoughts on passing properties.
+@@ -368,6 +384,8 @@
+ fEntityManager = (XMLEntityManager)propertyManager.getProperty(ENTITY_MANAGER);
+ fEntityStore = fEntityManager.getEntityStore() ;
+ fEntityScanner = (XMLEntityScanner)fEntityManager.getEntityScanner() ;
++ fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(SECURITY_MANAGER);
++
+ //fEntityManager.reset();
+ // DTD preparsing defaults:
+ fValidation = false;
+@@ -526,8 +544,9 @@
+ sawSpace = fEntityScanner.skipSpaces();
+ }
+ // restore original literal value
+- if(currLiteral)
++ if(currLiteral) {
+ currEnt.literal = true;
++ }
+ // REVISIT: should we remove this error reporting?
+ if (scanningTextDecl && state != STATE_DONE) {
+ reportFatalError("MorePseudoAttributes", null);
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Tue Oct 29 08:01:29 2013 +0000
+@@ -289,8 +289,10 @@
+ InvalidCharInLiteral=InvalidCharInLiteral
+
+
+-#Application can set the limit of number of entities that should be expanded by the parser.
+-EntityExpansionLimitExceeded=The parser has encountered more than \"{0}\" entity expansions in this document; this is the limit imposed by the application.
++# Implementation limits
++ EntityExpansionLimitExceeded=JAXP00010001: The parser has encountered more than \"{0}\" entity expansions in this document; this is the limit imposed by the JDK.
++ ElementAttributeLimit=JAXP00010002: Element \"{0}\" has more than \"{1}\" attributes, \"{1}\" is the limit imposed by the JDK.
++ MaxEntitySizeLimit=JAXP00010003: The length of entity \"{0}\" is \"{1}\" that exceeds the \"{2}\" limit set by \"{3}\".
++ TotalEntitySizeLimit=JAXP00010004: The accumulated size \"{0}\" of entities exceeded the \"{1}\" limit set by \"{2}\".
++ MaxXMLNameLimit=JAXP00010005: The name \"{0}\" exceeded the \"{1}\" limit set by \"{2}\".
+
+-# Application can set the limit of number of attributes of entity that should be expanded by the parser.
+-ElementAttributeLimit= Element \"{0}\" has more than \"{1}\" attributes, \"{1}\" is the limit imposed by the application.
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java Tue Oct 29 08:01:29 2013 +0000
+@@ -111,7 +111,8 @@
+ }
+
+ public void nodeCountCheck(){
+- if( fSecurityManager != null && nodeCount++ > maxNodeLimit){
++ if( fSecurityManager != null && !fSecurityManager.isNoLimit(maxNodeLimit) &&
++ nodeCount++ > maxNodeLimit){
+ if(DEBUG){
+ System.out.println("nodeCount = " + nodeCount ) ;
+ System.out.println("nodeLimit = " + maxNodeLimit ) ;
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -108,6 +108,8 @@
+ /** Initial EntityResolver */
+ private final EntityResolver fInitEntityResolver;
+
++ private XMLSecurityManager fSecurityManager;
++
+ DocumentBuilderImpl(DocumentBuilderFactoryImpl dbf, Hashtable dbfAttrs, Hashtable features)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
+ this(dbf, dbfAttrs, features, false);
+@@ -151,10 +153,8 @@
+ domParser.setFeature(XINCLUDE_FEATURE, true);
+ }
+
+- // If the secure processing feature is on set a security manager.
+- if (secureProcessing) {
+- domParser.setProperty(SECURITY_MANAGER, new XMLSecurityManager());
+- }
++ fSecurityManager = new XMLSecurityManager(secureProcessing);
++ domParser.setProperty(SECURITY_MANAGER, fSecurityManager);
+
+ this.grammar = dbf.getSchema();
+ if (grammar != null) {
+@@ -202,9 +202,9 @@
+ String feature = (String)e.nextElement();
+ boolean value = ((Boolean)features.get(feature)).booleanValue();
+ domParser.setFeature(feature, value);
+- }
+ }
+ }
++ }
+
+ /**
+ * Set any DocumentBuilderFactory attributes of our underlying DOMParser
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Tue Oct 29 08:01:29 2013 +0000
+@@ -105,6 +105,8 @@
+ /** Initial EntityResolver */
+ private final EntityResolver fInitEntityResolver;
+
++ private final XMLSecurityManager fSecurityManager;
++
+ /**
+ * Create a SAX parser with the associated features
+ * @param features Hashtable of SAX features, may be null
+@@ -121,8 +123,9 @@
+ SAXParserImpl(SAXParserFactoryImpl spf, Hashtable features, boolean secureProcessing)
+ throws SAXException
+ {
++ fSecurityManager = new XMLSecurityManager(secureProcessing);
+ // Instantiate a SAXParser directly and not through SAX so that we use the right ClassLoader
+- xmlReader = new JAXPSAXParser(this);
++ xmlReader = new JAXPSAXParser(this, fSecurityManager);
+
+ // JAXP "namespaceAware" == SAX Namespaces feature
+ // Note: there is a compatibility problem here with default values:
+@@ -141,10 +144,7 @@
+ xmlReader.setFeature0(XINCLUDE_FEATURE, true);
+ }
+
+- // If the secure processing feature is on set a security manager.
+- if (secureProcessing) {
+- xmlReader.setProperty0(SECURITY_MANAGER, new XMLSecurityManager());
+- }
++ xmlReader.setProperty0(SECURITY_MANAGER, fSecurityManager);
+
+ // Set application's features, followed by validation features.
+ setFeatures(features);
+@@ -326,14 +326,28 @@
+ private HashMap fInitFeatures = new HashMap();
+ private HashMap fInitProperties = new HashMap();
+ private SAXParserImpl fSAXParser;
++ private XMLSecurityManager fSecurityManager;
+
+ public JAXPSAXParser() {
+- super();
++ this(null, null);
+ }
+
+- JAXPSAXParser(SAXParserImpl saxParser) {
++ JAXPSAXParser(SAXParserImpl saxParser, XMLSecurityManager securityManager) {
+ super();
+ fSAXParser = saxParser;
++ fSecurityManager = securityManager;
++ /**
++ * This class may be used directly. So initialize the security manager if
++ * it is null.
++ */
++ if (fSecurityManager == null) {
++ fSecurityManager = new XMLSecurityManager(true);
++ try {
++ super.setProperty(SECURITY_MANAGER, fSecurityManager);
++ } catch (Exception ex) {
++ //shall not happen
++ }
++ }
+ }
+
+ /**
+@@ -349,7 +363,8 @@
+ }
+ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+ try {
+- setProperty(SECURITY_MANAGER, value ? new XMLSecurityManager() : null);
++ fSecurityManager.setSecureProcessing(value);
++ setProperty(SECURITY_MANAGER, fSecurityManager);
+ }
+ catch (SAXNotRecognizedException exc) {
+ // If the property is not supported
+@@ -385,13 +400,7 @@
+ throw new NullPointerException();
+ }
+ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+- try {
+- return (super.getProperty(SECURITY_MANAGER) != null);
+- }
+- // If the property is not supported the value must be false.
+- catch (SAXException exc) {
+- return false;
+- }
++ return fSecurityManager.isSecureProcessing();
+ }
+ return super.getFeature(name);
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java Tue Oct 29 08:01:29 2013 +0000
+@@ -40,8 +40,15 @@
+ */
+ private final HashMap fFeatures;
+
++ /**
++ * Map containing the initial values of properties for
++ * validators created using this grammar pool container.
++ */
++ private final HashMap<String,Object> fProperties;
++
+ public AbstractXMLSchema() {
+ fFeatures = new HashMap();
++ fProperties = new HashMap<String,Object>();
+ }
+
+ /*
+@@ -83,4 +90,20 @@
+ fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
+ }
+
++ /**
++ * Returns the initial value of a property for validators created
++ * using this grammar pool container or null if the validators
++ * should use the default value.
++ */
++ public final Object getProperty(String propertyId) {
++ return fProperties.get(propertyId);
++ }
++
++ /*
++ * Set a property on the schema
++ */
++ public final void setProperty(String propertyId, Object state) {
++ fProperties.put(propertyId, state);
++ }
++
+ } // AbstractXMLSchema
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StAXValidatorHelper.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StAXValidatorHelper.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StAXValidatorHelper.java Tue Oct 29 08:01:29 2013 +0000
+@@ -25,6 +25,9 @@
+
+ package com.sun.org.apache.xerces.internal.jaxp.validation;
+
++import com.sun.org.apache.xerces.internal.impl.Constants;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
++
+ import java.io.IOException;
+
+ import javax.xml.transform.Result;
+@@ -68,6 +71,19 @@
+ if( identityTransformer1==null ) {
+ try {
+ SAXTransformerFactory tf = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
++ XMLSecurityManager securityManager = (XMLSecurityManager)fComponentManager.getProperty(Constants.SECURITY_MANAGER);
++ if (securityManager != null) {
++ for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
++ if (securityManager.isSet(limit.ordinal())){
++ tf.setAttribute(limit.apiProperty(),
++ securityManager.getLimitValueAsString(limit));
++ }
++ }
++ if (securityManager.printEntityCountInfo()) {
++ tf.setAttribute(Constants.JDK_ENTITY_COUNT_INFO, "yes");
++ }
++ }
++
+ identityTransformer1 = tf.newTransformer();
+ identityTransformer2 = tf.newTransformerHandler();
+ } catch (TransformerConfigurationException e) {
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Tue Oct 29 08:01:29 2013 +0000
+@@ -184,6 +184,8 @@
+ config.setDocumentHandler(fSchemaValidator);
+ config.setDTDHandler(null);
+ config.setDTDContentModelHandler(null);
++ config.setProperty(Constants.SECURITY_MANAGER,
++ fComponentManager.getProperty(Constants.SECURITY_MANAGER));
+ fConfiguration = new SoftReference(config);
+ return config;
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 08:01:29 2013 +0000
+@@ -97,7 +97,7 @@
+ /** The ErrorHandlerWrapper */
+ private ErrorHandlerWrapper fErrorHandlerWrapper;
+
+- /** The XMLSecurityManager. */
++ /** The SecurityManager. */
+ private XMLSecurityManager fSecurityManager;
+
+ /** The container for the real grammar pool. */
+@@ -113,7 +113,7 @@
+ fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper);
+
+ // Enable secure processing feature by default
+- fSecurityManager = new XMLSecurityManager();
++ fSecurityManager = new XMLSecurityManager(true);
+ fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
+ }
+
+@@ -292,7 +292,7 @@
+ "property-not-supported", new Object [] {name}));
+ }
+ try {
+- return fXMLSchemaLoader.getProperty(name);
++ return fXMLSchemaLoader.getProperty(name);
+ }
+ catch (XMLConfigurationException e) {
+ String identifier = e.getIdentifier();
+@@ -321,7 +321,9 @@
+ SAXMessageFormatter.formatMessage(null,
+ "jaxp-secureprocessing-feature", null));
+ }
++
+ fSecurityManager = value ? new XMLSecurityManager() : null;
++ fSecurityManager.setSecureProcessing(value);
+ fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
+ return;
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Tue Oct 29 08:01:29 2013 +0000
+@@ -173,7 +173,7 @@
+ private final HashMap fInitProperties = new HashMap();
+
+ /** Stores the initial security manager. */
+- private final XMLSecurityManager fInitSecurityManager;
++ private XMLSecurityManager fInitSecurityManager;
+
+ //
+ // User Objects
+@@ -210,12 +210,6 @@
+ fComponents.put(ENTITY_RESOLVER, null);
+ fComponents.put(ERROR_HANDLER, null);
+
+- if (System.getSecurityManager() != null) {
+- _isSecureMode = true;
+- setProperty(SECURITY_MANAGER, new XMLSecurityManager());
+- } else {
+- fComponents.put(SECURITY_MANAGER, null);
+- }
+ fComponents.put(SYMBOL_TABLE, new SymbolTable());
+
+ // setup grammar pool
+@@ -230,15 +224,21 @@
+ addRecognizedParamsAndSetDefaults(fErrorReporter, grammarContainer);
+ addRecognizedParamsAndSetDefaults(fSchemaValidator, grammarContainer);
+
+- // if the secure processing feature is set to true, add a security manager to the configuration
+- Boolean secureProcessing = grammarContainer.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
+- if (Boolean.TRUE.equals(secureProcessing)) {
+- fInitSecurityManager = new XMLSecurityManager();
++ boolean secureProcessing = grammarContainer.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
++ if (System.getSecurityManager() != null) {
++ _isSecureMode = true;
++ secureProcessing = true;
+ }
+- else {
+- fInitSecurityManager = null;
++
++ fInitSecurityManager = (XMLSecurityManager)
++ grammarContainer.getProperty(SECURITY_MANAGER);
++ if (fInitSecurityManager != null ) {
++ fInitSecurityManager.setSecureProcessing(secureProcessing);
++ } else {
++ fInitSecurityManager = new XMLSecurityManager(secureProcessing);
+ }
+- fComponents.put(SECURITY_MANAGER, fInitSecurityManager);
++
++ setProperty(SECURITY_MANAGER, fInitSecurityManager);
+
+ }
+
+@@ -266,7 +266,7 @@
+ return fUseGrammarPoolOnly;
+ }
+ else if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) {
+- return getProperty(SECURITY_MANAGER) != null;
++ return fInitSecurityManager.isSecureProcessing();
+ }
+ else if (SCHEMA_ELEMENT_DEFAULT.equals(featureId)) {
+ return true; //pre-condition: VALIDATION and SCHEMA_VALIDATION are always true
+@@ -296,7 +296,8 @@
+ if (_isSecureMode && !value) {
+ throw new XMLConfigurationException(XMLConfigurationException.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING);
+ }
+- setProperty(SECURITY_MANAGER, value ? new XMLSecurityManager() : null);
++ fInitSecurityManager.setSecureProcessing(value);
++ setProperty(SECURITY_MANAGER, fInitSecurityManager);
+ return;
+ }
+ fConfigUpdated = true;
+@@ -366,10 +367,12 @@
+ fComponents.put(propertyId, value);
+ return;
+ }
+- if (!fInitProperties.containsKey(propertyId)) {
+- fInitProperties.put(propertyId, super.getProperty(propertyId));
+- }
+- super.setProperty(propertyId, value);
++
++ //fall back to the existing property manager
++ if (!fInitProperties.containsKey(propertyId)) {
++ fInitProperties.put(propertyId, super.getProperty(propertyId));
++ }
++ super.setProperty(propertyId, value);
+ }
+
+ /**
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java Tue Oct 29 08:01:29 2013 +0000
+@@ -54,4 +54,11 @@
+ */
+ public Boolean getFeature(String featureId);
+
++ /**
++ * Returns the initial value of a property for validators created
++ * using this grammar pool container or null if the validators
++ * should use the default value.
++ */
++ public Object getProperty(String propertyId);
++
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Oct 29 08:01:29 2013 +0000
+@@ -22,6 +22,7 @@
+
+ import com.sun.org.apache.xerces.internal.impl.Constants;
+ import com.sun.org.apache.xerces.internal.util.SymbolTable;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
+
+@@ -73,6 +74,7 @@
+ XMLGRAMMAR_POOL,
+ };
+
++ XMLSecurityManager securityManager;
+ //
+ // Constructors
+ //
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java Tue Oct 29 08:01:29 2013 +0000
+@@ -44,6 +44,7 @@
+ *
+ * @author Neil Graham, IBM
+ *
++ * @version $Id: SecurityConfiguration.java,v 1.6 2010-11-01 04:40:09 joehw Exp $
+ */
+ public class SecurityConfiguration extends XIncludeAwareParserConfiguration
+ {
+@@ -106,8 +107,8 @@
+ XMLComponentManager parentSettings) {
+ super(symbolTable, grammarPool, parentSettings);
+
+- // create the XMLSecurityManager property:
+- setProperty(SECURITY_MANAGER_PROPERTY, new XMLSecurityManager());
++ // create the SecurityManager property:
++ setProperty(SECURITY_MANAGER_PROPERTY, new XMLSecurityManager(true));
+ } // <init>(SymbolTable,XMLGrammarPool)
+
+ } // class SecurityConfiguration
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Tue Oct 29 08:01:29 2013 +0000
+@@ -20,6 +20,12 @@
+
+ package com.sun.org.apache.xerces.internal.parsers;
+
++import java.io.IOException;
++import java.util.ArrayList;
++import java.util.HashMap;
++import java.util.Locale;
++import javax.xml.XMLConstants;
++
+ import com.sun.org.apache.xerces.internal.impl.Constants;
+ import com.sun.org.apache.xerces.internal.impl.XML11DTDScannerImpl;
+ import com.sun.org.apache.xerces.internal.impl.XML11DocumentScannerImpl;
+@@ -44,6 +50,7 @@
+ import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
+ import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
+ import com.sun.org.apache.xerces.internal.util.SymbolTable;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler;
+ import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler;
+ import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
+@@ -60,11 +67,6 @@
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration;
+-import java.io.IOException;
+-import java.util.ArrayList;
+-import java.util.HashMap;
+-import java.util.Locale;
+-import javax.xml.XMLConstants;
+
+ /**
+ * This class is the configuration used to parse XML 1.0 and XML 1.1 documents.
+@@ -259,6 +261,9 @@
+ protected static final String LOCALE =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
+
++ /** Property identifier: Security manager. */
++ private static final String SECURITY_MANAGER = Constants.SECURITY_MANAGER;
++
+ // debugging
+
+ /** Set to true and recompile to print exception stack trace. */
+@@ -268,33 +273,33 @@
+ // Data
+ //
+
+- protected SymbolTable fSymbolTable;
++ protected SymbolTable fSymbolTable;
+ protected XMLInputSource fInputSource;
+ protected ValidationManager fValidationManager;
+- protected XMLVersionDetector fVersionDetector;
++ protected XMLVersionDetector fVersionDetector;
+ protected XMLLocator fLocator;
+- protected Locale fLocale;
++ protected Locale fLocale;
+
+- /** XML 1.0 Components. */
+- protected ArrayList fComponents;
++ /** XML 1.0 Components. */
++ protected ArrayList fComponents;
+
+- /** XML 1.1. Components. */
+- protected ArrayList fXML11Components = null;
+-
+- /** Common components: XMLEntityManager, XMLErrorReporter, XMLSchemaValidator */
+- protected ArrayList fCommonComponents = null;
++ /** XML 1.1. Components. */
++ protected ArrayList fXML11Components = null;
++
++ /** Common components: XMLEntityManager, XMLErrorReporter, XMLSchemaValidator */
++ protected ArrayList fCommonComponents = null;
+
+- /** The document handler. */
+- protected XMLDocumentHandler fDocumentHandler;
++ /** The document handler. */
++ protected XMLDocumentHandler fDocumentHandler;
+
+- /** The DTD handler. */
+- protected XMLDTDHandler fDTDHandler;
++ /** The DTD handler. */
++ protected XMLDTDHandler fDTDHandler;
++
++ /** The DTD content model handler. */
++ protected XMLDTDContentModelHandler fDTDContentModelHandler;
+
+- /** The DTD content model handler. */
+- protected XMLDTDContentModelHandler fDTDContentModelHandler;
+-
+- /** Last component in the document pipeline */
+- protected XMLDocumentSource fLastComponent;
++ /** Last component in the document pipeline */
++ protected XMLDocumentSource fLastComponent;
+
+ /**
+ * True if a parse is in progress. This state is needed because
+@@ -510,6 +515,7 @@
+ SCHEMA_LOCATION,
+ SCHEMA_NONS_LOCATION,
+ LOCALE,
++ SECURITY_MANAGER,
+ };
+ addRecognizedProperties(recognizedProperties);
+
+@@ -557,6 +563,8 @@
+
+ fVersionDetector = new XMLVersionDetector();
+
++ fProperties.put(SECURITY_MANAGER, new XMLSecurityManager(true));
++
+ // add message formatters
+ if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
+ XMLMessageFormatter xmft = new XMLMessageFormatter();
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java Tue Oct 29 08:01:29 2013 +0000
+@@ -23,6 +23,7 @@
+ import java.io.File;
+ import java.io.FileInputStream;
+ import java.io.FileNotFoundException;
++import java.io.IOException;
+ import java.io.InputStream;
+
+ import java.security.AccessController;
+@@ -31,6 +32,7 @@
+ import java.security.PrivilegedExceptionAction;
+ import java.util.Locale;
+ import java.util.MissingResourceException;
++import java.util.Properties;
+ import java.util.PropertyResourceBundle;
+ import java.util.ResourceBundle;
+
+@@ -195,5 +197,55 @@
+ })).longValue();
+ }
+
++ /**
++ * Read from $java.home/lib/jaxp.properties for the specified property
++ * The program
++ *
++ * @param propertyId the Id of the property
++ * @return the value of the property
++ */
++ static String readJAXPProperty(String propertyId) {
++ String value = null;
++ InputStream is = null;
++ try {
++ if (firstTime) {
++ synchronized (cacheProps) {
++ if (firstTime) {
++ String configFile = getSystemProperty("java.home") + File.separator +
++ "lib" + File.separator + "jaxp.properties";
++ File f = new File(configFile);
++ if (getFileExists(f)) {
++ is = getFileInputStream(f);
++ cacheProps.load(is);
++ }
++ firstTime = false;
++ }
++ }
++ }
++ value = cacheProps.getProperty(propertyId);
++
++ }
++ catch (Exception ex) {}
++ finally {
++ if (is != null) {
++ try {
++ is.close();
++ } catch (IOException ex) {}
++ }
++ }
++
++ return value;
++ }
++
++ /**
++ * Cache for properties in java.home/lib/jaxp.properties
++ */
++ static final Properties cacheProps = new Properties();
++
++ /**
++ * Flag indicating if the program has tried reading java.home/lib/jaxp.properties
++ */
++ static volatile boolean firstTime = true;
++
+ private SecuritySupport () {}
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java Tue Oct 29 08:01:29 2013 +0000
+@@ -0,0 +1,236 @@
++/*
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
++ *
++ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
++ *
++ * The contents of this file are subject to the terms of either the GNU
++ * General Public License Version 2 only ("GPL") or the Common Development
++ * and Distribution License("CDDL") (collectively, the "License"). You
++ * may not use this file except in compliance with the License. You can
++ * obtain a copy of the License at
++ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
++ * or packager/legal/LICENSE.txt. See the License for the specific
++ * language governing permissions and limitations under the License.
++ *
++ * When distributing the software, include this License Header Notice in each
++ * file and include the License file at packager/legal/LICENSE.txt.
++ *
++ * GPL Classpath Exception:
++ * Oracle designates this particular file as subject to the "Classpath"
++ * exception as provided by Oracle in the GPL Version 2 section of the License
++ * file that accompanied this code.
++ *
++ * Modifications:
++ * If applicable, add the following below the License Header, with the fields
++ * enclosed by brackets [] replaced by your own identifying information:
++ * "Portions Copyright [year] [name of copyright owner]"
++ *
++ * Contributor(s):
++ * If you wish your version of this file to be governed by only the CDDL or
++ * only the GPL Version 2, indicate your decision by adding "[Contributor]
++ * elects to include this software in this distribution under the [CDDL or GPL
++ * Version 2] license." If you don't indicate a single choice of license, a
++ * recipient has the option to distribute your version of this file under
++ * either the CDDL, the GPL Version 2 or to extend the choice of license to
++ * its licensees as provided above. However, if you add GPL Version 2 code
++ * and therefore, elected the GPL Version 2 license, then the option applies
++ * only if the new code is made subject to such option by the copyright
++ * holder.
++ */
++package com.sun.org.apache.xerces.internal.utils;
++
++import com.sun.org.apache.xerces.internal.impl.Constants;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
++import java.util.Formatter;
++import java.util.HashMap;
++import java.util.Map;
++
++/**
++ * A helper for analyzing entity expansion limits
++ *
++ * @author Joe Wang Oracle Corp.
++ *
++ */
++public final class XMLLimitAnalyzer {
++
++ /**
++ * Map old property names with the new ones
++ */
++ public static enum NameMap {
++ ENTITY_EXPANSION_LIMIT(Constants.SP_ENTITY_EXPANSION_LIMIT, Constants.ENTITY_EXPANSION_LIMIT),
++ MAX_OCCUR_NODE_LIMIT(Constants.SP_MAX_OCCUR_LIMIT, Constants.MAX_OCCUR_LIMIT),
++ ELEMENT_ATTRIBUTE_LIMIT(Constants.SP_ELEMENT_ATTRIBUTE_LIMIT, Constants.ELEMENT_ATTRIBUTE_LIMIT);
++
++ final String newName;
++ final String oldName;
++
++ NameMap(String newName, String oldName) {
++ this.newName = newName;
++ this.oldName = oldName;
++ }
++
++ String getOldName(String newName) {
++ if (newName.equals(this.newName)) {
++ return oldName;
++ }
++ return null;
++ }
++ }
++
++ private XMLSecurityManager securityManager;
++ /**
++ * Max value accumulated for each property
++ */
++ private final int[] values;
++ /**
++ * Names of the entities corresponding to their max values
++ */
++ private final String[] names;
++ /**
++ * Total value of accumulated entities
++ */
++ private final int[] totalValue;
++
++ /**
++ * Maintain values of the top 10 elements in the process of parsing
++ */
++ private final Map[] caches;
++
++ private String entityStart, entityEnd;
++ /**
++ * Default constructor. Establishes default values for known security
++ * vulnerabilities.
++ */
++ public XMLLimitAnalyzer(XMLSecurityManager securityManager) {
++ this.securityManager = securityManager;
++ values = new int[Limit.values().length];
++ totalValue = new int[Limit.values().length];
++ names = new String[Limit.values().length];
++ caches = new Map[Limit.values().length];
++ }
++
++ /**
++ * Add the value to the current max count for the specified property
++ * To find the max value of all entities, set no limit
++ *
++ * @param limit the type of the property
++ * @param entityName the name of the entity
++ * @param value the value of the entity
++ */
++ public void addValue(Limit limit, String entityName, int value) {
++ addValue(limit.ordinal(), entityName, value);
++ }
++
++ /**
++ * Add the value to the current count by the index of the property
++ * @param index the index of the property
++ * @param entityName the name of the entity
++ * @param value the value of the entity
++ */
++ public void addValue(int index, String entityName, int value) {
++ if (index == Limit.ENTITY_EXPANSION_LIMIT.ordinal() ||
++ index == Limit.MAX_OCCUR_NODE_LIMIT.ordinal() ||
++ index == Limit.ELEMENT_ATTRIBUTE_LIMIT.ordinal()) {
++ totalValue[index] += value;
++ return;
++ }
++
++ Map<String, Integer> cache;
++ if (caches[index] == null) {
++ cache = new HashMap<String, Integer>(10);
++ caches[index] = cache;
++ } else {
++ cache = caches[index];
++ }
++
++ int accumulatedValue = value;
++ if (cache.containsKey(entityName)) {
++ accumulatedValue += cache.get(entityName).intValue();
++ cache.put(entityName, Integer.valueOf(accumulatedValue));
++ } else {
++ cache.put(entityName, Integer.valueOf(value));
++ }
++
++ if (accumulatedValue > values[index]) {
++ values[index] = accumulatedValue;
++ names[index] = entityName;
++ }
++
++
++ if (index == Limit.GENEAL_ENTITY_SIZE_LIMIT.ordinal() ||
++ index == Limit.PARAMETER_ENTITY_SIZE_LIMIT.ordinal()) {
++ totalValue[Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal()] += value;
++ }
++ }
++
++ /**
++ * Return the value of the current max count for the specified property
++ *
++ * @param limit the property
++ * @return the value of the property
++ */
++ public int getValue(Limit limit) {
++ return values[limit.ordinal()];
++ }
++
++ public int getValue(int index) {
++ return values[index];
++ }
++ /**
++ * Return the total value accumulated so far
++ *
++ * @param limit the property
++ * @return the accumulated value of the property
++ */
++ public int getTotalValue(Limit limit) {
++ return totalValue[limit.ordinal()];
++ }
++
++ public int getTotalValue(int index) {
++ return totalValue[index];
++ }
++ /**
++ * Return the current max value (count or length) by the index of a property
++ * @param index the index of a property
++ * @return count of a property
++ */
++ public int getValueByIndex(int index) {
++ return values[index];
++ }
++
++ public void startEntity(String name) {
++ entityStart = name;
++ }
++
++ public boolean isTracking(String name) {
++ return entityStart.equals(name);
++ }
++ /**
++ * Stop tracking the entity
++ * @param limit the limit property
++ * @param name the name of an entity
++ */
++ public void endEntity(Limit limit, String name) {
++ entityStart = "";
++ Map<String, Integer> cache = caches[limit.ordinal()];
++ if (cache != null) {
++ cache.remove(name);
++ }
++ }
++
++ public void debugPrint() {
++ Formatter formatter = new Formatter();
++ System.out.println(formatter.format("%30s %15s %15s %15s %30s",
++ "Property","Limit","Total size","Size","Entity Name"));
++
++ for (Limit limit : Limit.values()) {
++ formatter = new Formatter();
++ System.out.println(formatter.format("%30s %15d %15d %15d %30s",
++ limit.name(),
++ securityManager.getLimit(limit),
++ totalValue[limit.ordinal()],
++ values[limit.ordinal()],
++ names[limit.ordinal()]));
++ }
++ }
++}
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Tue Oct 29 08:01:29 2013 +0000
+@@ -40,108 +40,482 @@
+ */
+ public static enum State {
+ //this order reflects the overriding order
+- DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY
++
++ DEFAULT("default"), FSP("FEATURE_SECURE_PROCESSING"),
++ JAXPDOTPROPERTIES("jaxp.properties"), SYSTEMPROPERTY("system property"),
++ APIPROPERTY("property");
++
++ final String literal;
++ State(String literal) {
++ this.literal = literal;
++ }
++
++ String literal() {
++ return literal;
++ }
+ }
+
+ /**
+ * Limits managed by the security manager
+ */
+ public static enum Limit {
+- ENTITY_EXPANSION_LIMIT(64000),
+- MAX_OCCUR_NODE_LIMIT(5000),
+- ELEMENT_ATTRIBUTE_LIMIT(10000);
+
++ ENTITY_EXPANSION_LIMIT(Constants.JDK_ENTITY_EXPANSION_LIMIT, Constants.SP_ENTITY_EXPANSION_LIMIT, 0, 64000),
++ MAX_OCCUR_NODE_LIMIT(Constants.JDK_MAX_OCCUR_LIMIT, Constants.SP_MAX_OCCUR_LIMIT, 0, 5000),
++ ELEMENT_ATTRIBUTE_LIMIT(Constants.JDK_ELEMENT_ATTRIBUTE_LIMIT, Constants.SP_ELEMENT_ATTRIBUTE_LIMIT, 0, 10000),
++ TOTAL_ENTITY_SIZE_LIMIT(Constants.JDK_TOTAL_ENTITY_SIZE_LIMIT, Constants.SP_TOTAL_ENTITY_SIZE_LIMIT, 0, 50000000),
++ GENEAL_ENTITY_SIZE_LIMIT(Constants.JDK_GENEAL_ENTITY_SIZE_LIMIT, Constants.SP_GENEAL_ENTITY_SIZE_LIMIT, 0, 0),
++ PARAMETER_ENTITY_SIZE_LIMIT(Constants.JDK_PARAMETER_ENTITY_SIZE_LIMIT, Constants.SP_PARAMETER_ENTITY_SIZE_LIMIT, 0, 1000000);
++
++ final String apiProperty;
++ final String systemProperty;
+ final int defaultValue;
++ final int secureValue;
+
+- Limit(int value) {
++ Limit(String apiProperty, String systemProperty, int value, int secureValue) {
++ this.apiProperty = apiProperty;
++ this.systemProperty = systemProperty;
+ this.defaultValue = value;
++ this.secureValue = secureValue;
++ }
++
++ public boolean equalsAPIPropertyName(String propertyName) {
++ return (propertyName == null) ? false : apiProperty.equals(propertyName);
++ }
++
++ public boolean equalsSystemPropertyName(String propertyName) {
++ return (propertyName == null) ? false : systemProperty.equals(propertyName);
++ }
++
++ public String apiProperty() {
++ return apiProperty;
++ }
++
++ String systemProperty() {
++ return systemProperty;
+ }
+
+ int defaultValue() {
+ return defaultValue;
+ }
++
++ int secureValue() {
++ return secureValue;
++ }
+ }
+
+ /**
+- * Values of the limits as defined in enum Limit
++ * Map old property names with the new ones
+ */
+- private final int[] limits;
++ public static enum NameMap {
++
++ ENTITY_EXPANSION_LIMIT(Constants.SP_ENTITY_EXPANSION_LIMIT, Constants.ENTITY_EXPANSION_LIMIT),
++ MAX_OCCUR_NODE_LIMIT(Constants.SP_MAX_OCCUR_LIMIT, Constants.MAX_OCCUR_LIMIT),
++ ELEMENT_ATTRIBUTE_LIMIT(Constants.SP_ELEMENT_ATTRIBUTE_LIMIT, Constants.ELEMENT_ATTRIBUTE_LIMIT);
++ final String newName;
++ final String oldName;
++
++ NameMap(String newName, String oldName) {
++ this.newName = newName;
++ this.oldName = oldName;
++ }
++
++ String getOldName(String newName) {
++ if (newName.equals(this.newName)) {
++ return oldName;
++ }
++ return null;
++ }
++ }
++ private static final int NO_LIMIT = 0;
+ /**
+- * States of the settings for each limit in limits above
++ * Values of the properties
+ */
+- private State[] states = {State.DEFAULT, State.DEFAULT, State.DEFAULT, State.DEFAULT};
++ private final int[] values;
++ /**
++ * States of the settings for each property
++ */
++ private State[] states;
++ /**
++ * Flag indicating if secure processing is set
++ */
++ boolean secureProcessing;
++
++ /**
++ * States that determine if properties are set explicitly
++ */
++ private boolean[] isSet;
++
++
++ private XMLLimitAnalyzer limitAnalyzer;
++ /**
++ * Index of the special entityCountInfo property
++ */
++ private int indexEntityCountInfo = 10000;
++ private String printEntityCountInfo = "";
+
+ /**
+ * Default constructor. Establishes default values for known security
+ * vulnerabilities.
+ */
+ public XMLSecurityManager() {
+- limits = new int[Limit.values().length];
++ this(false);
++ }
++
++ /**
++ * Instantiate Security Manager in accordance with the status of
++ * secure processing
++ * @param secureProcessing
++ */
++ public XMLSecurityManager(boolean secureProcessing) {
++ limitAnalyzer = new XMLLimitAnalyzer(this);
++ values = new int[Limit.values().length];
++ states = new State[Limit.values().length];
++ isSet = new boolean[Limit.values().length];
++ this.secureProcessing = secureProcessing;
+ for (Limit limit : Limit.values()) {
+- limits[limit.ordinal()] = limit.defaultValue();
++ if (secureProcessing) {
++ values[limit.ordinal()] = limit.secureValue;
++ states[limit.ordinal()] = State.FSP;
++ } else {
++ values[limit.ordinal()] = limit.defaultValue();
++ states[limit.ordinal()] = State.DEFAULT;
++ }
+ }
+ //read system properties or jaxp.properties
+ readSystemProperties();
+ }
+
+ /**
+- * Sets the limit for a specific type of XML constructs. This can be either
+- * the size or the number of the constructs.
+- *
+- * @param type the type of limitation
+- * @param state the state of limitation
+- * @param limit the limit to the type
++ * Setting FEATURE_SECURE_PROCESSING explicitly
+ */
+- public void setLimit(Limit limit, State state, int value) {
+- //only update if it shall override
+- if (state.compareTo(states[limit.ordinal()]) >= 0) {
+- limits[limit.ordinal()] = value;
+- states[limit.ordinal()] = state;
++ public void setSecureProcessing(boolean secure) {
++ secureProcessing = secure;
++ for (Limit limit : Limit.values()) {
++ if (secure) {
++ setLimit(limit.ordinal(), State.FSP, limit.secureValue());
++ } else {
++ setLimit(limit.ordinal(), State.FSP, limit.defaultValue());
++ }
+ }
+ }
+
+ /**
+- * Returns the limit set for the type specified
++ * Return the state of secure processing
++ * @return the state of secure processing
++ */
++ public boolean isSecureProcessing() {
++ return secureProcessing;
++ }
++
++
++ /**
++ * Set limit by property name and state
++ * @param propertyName property name
++ * @param state the state of the property
++ * @param value the value of the property
++ * @return true if the property is managed by the security manager; false
++ * if otherwise.
++ */
++ public boolean setLimit(String propertyName, State state, Object value) {
++ int index = getIndex(propertyName);
++ if (index > -1) {
++ setLimit(index, state, value);
++ return true;
++ }
++ return false;
++ }
++
++ /**
++ * Set the value for a specific limit.
+ *
+- * @param limit the type of limitation
+- * @return the limit to the type
++ * @param limit the limit
++ * @param state the state of the property
++ * @param value the value of the property
++ */
++ public void setLimit(Limit limit, State state, int value) {
++ setLimit(limit.ordinal(), state, value);
++ }
++
++ /**
++ * Set the value of a property by its index
++ *
++ * @param index the index of the property
++ * @param state the state of the property
++ * @param value the value of the property
++ */
++ public void setLimit(int index, State state, Object value) {
++ if (index == indexEntityCountInfo) {
++ printEntityCountInfo = (String)value;
++ } else {
++ int temp = 0;
++ try {
++ temp = Integer.parseInt((String) value);
++ if (temp < 0) {
++ temp = 0;
++ }
++ } catch (NumberFormatException e) {}
++ setLimit(index, state, temp);
++ }
++ }
++
++ /**
++ * Set the value of a property by its index
++ *
++ * @param index the index of the property
++ * @param state the state of the property
++ * @param value the value of the property
++ */
++ public void setLimit(int index, State state, int value) {
++ if (index == indexEntityCountInfo) {
++ //if it's explicitly set, it's treated as yes no matter the value
++ printEntityCountInfo = Constants.JDK_YES;
++ } else {
++ //only update if it shall override
++ if (state.compareTo(states[index]) >= 0) {
++ values[index] = value;
++ states[index] = state;
++ isSet[index] = true;
++ }
++ }
++ }
++
++ /**
++ * Return the value of the specified property
++ *
++ * @param propertyName the property name
++ * @return the value of the property as a string. If a property is managed
++ * by this manager, its value shall not be null.
++ */
++ public String getLimitAsString(String propertyName) {
++ int index = getIndex(propertyName);
++ if (index > -1) {
++ return getLimitValueByIndex(index);
++ }
++
++ return null;
++ }
++ /**
++ * Return the value of the specified property
++ *
++ * @param limit the property
++ * @return the value of the property
+ */
+ public int getLimit(Limit limit) {
+- return limits[limit.ordinal()];
++ return values[limit.ordinal()];
++ }
++
++ /**
++ * Return the value of a property by its ordinal
++ *
++ * @param limit the property
++ * @return value of a property
++ */
++ public String getLimitValueAsString(Limit limit) {
++ return Integer.toString(values[limit.ordinal()]);
++ }
++
++ /**
++ * Return the value of a property by its ordinal
++ *
++ * @param index the index of a property
++ * @return limit of a property as a string
++ */
++ public String getLimitValueByIndex(int index) {
++ if (index == indexEntityCountInfo) {
++ return printEntityCountInfo;
++ }
++
++ return Integer.toString(values[index]);
++ }
++
++ /**
++ * Return the state of the limit property
++ *
++ * @param limit the limit
++ * @return the state of the limit property
++ */
++ public State getState(Limit limit) {
++ return states[limit.ordinal()];
++ }
++
++ /**
++ * Return the state of the limit property
++ *
++ * @param limit the limit
++ * @return the state of the limit property
++ */
++ public String getStateLiteral(Limit limit) {
++ return states[limit.ordinal()].literal();
++ }
++
++ /**
++ * Get the index by property name
++ *
++ * @param propertyName property name
++ * @return the index of the property if found; return -1 if not
++ */
++ public int getIndex(String propertyName) {
++ for (Limit limit : Limit.values()) {
++ if (limit.equalsAPIPropertyName(propertyName)) {
++ //internally, ordinal is used as index
++ return limit.ordinal();
++ }
++ }
++ //special property to return entity count info
++ if (propertyName.equals(Constants.JDK_ENTITY_COUNT_INFO)) {
++ return indexEntityCountInfo;
++ }
++ return -1;
++ }
++
++ /**
++ * Check if there's no limit defined by the Security Manager
++ * @param limit
++ * @return
++ */
++ public boolean isNoLimit(int limit) {
++ return limit==NO_LIMIT;
++ }
++ /**
++ * Check if the size (length or count) of the specified limit property is
++ * over the limit
++ *
++ * @param limit the type of the limit property
++ * @param entityName the name of the entity
++ * @param size the size (count or length) of the entity
++ * @return true if the size is over the limit, false otherwise
++ */
++ public boolean isOverLimit(Limit limit, String entityName, int size) {
++ return isOverLimit(limit.ordinal(), entityName, size);
++ }
++
++ /**
++ * Check if the value (length or count) of the specified limit property is
++ * over the limit
++ *
++ * @param index the index of the limit property
++ * @param entityName the name of the entity
++ * @param size the size (count or length) of the entity
++ * @return true if the size is over the limit, false otherwise
++ */
++ public boolean isOverLimit(int index, String entityName, int size) {
++ if (values[index] == NO_LIMIT) {
++ return false;
++ }
++ if (size > values[index]) {
++ limitAnalyzer.addValue(index, entityName, size);
++ return true;
++ }
++ return false;
++ }
++
++ /**
++ * Check against cumulated value
++ *
++ * @param limit the type of the limit property
++ * @param size the size (count or length) of the entity
++ * @return true if the size is over the limit, false otherwise
++ */
++ public boolean isOverLimit(Limit limit) {
++ return isOverLimit(limit.ordinal());
++ }
++
++ public boolean isOverLimit(int index) {
++ if (values[index] == NO_LIMIT) {
++ return false;
++ }
++
++ if (index==Limit.ELEMENT_ATTRIBUTE_LIMIT.ordinal() ||
++ index==Limit.ENTITY_EXPANSION_LIMIT.ordinal() ||
++ index==Limit.TOTAL_ENTITY_SIZE_LIMIT.ordinal()) {
++ return (limitAnalyzer.getTotalValue(index) > values[index]);
++ } else {
++ return (limitAnalyzer.getValue(index) > values[index]);
++ }
++ }
++
++ public void debugPrint() {
++ if (printEntityCountInfo.equals(Constants.JDK_YES)) {
++ limitAnalyzer.debugPrint();
++ }
++ }
++
++ /**
++ * Return the limit analyzer
++ *
++ * @return the limit analyzer
++ */
++ public XMLLimitAnalyzer getLimitAnalyzer() {
++ return limitAnalyzer;
++ }
++
++ /**
++ * Set limit analyzer
++ *
++ * @param analyzer a limit analyzer
++ */
++ public void setLimitAnalyzer(XMLLimitAnalyzer analyzer) {
++ limitAnalyzer = analyzer;
++ }
++
++ /**
++ * Indicate if a property is set explicitly
++ * @param index
++ * @return
++ */
++ public boolean isSet(int index) {
++ return isSet[index];
++ }
++
++ public boolean printEntityCountInfo() {
++ return printEntityCountInfo.equals(Constants.JDK_YES);
+ }
+
+ /**
+ * Read from system properties, or those in jaxp.properties
+ */
+ private void readSystemProperties() {
+- getSystemProperty(Limit.ENTITY_EXPANSION_LIMIT, Constants.ENTITY_EXPANSION_LIMIT);
+- getSystemProperty(Limit.MAX_OCCUR_NODE_LIMIT, Constants.MAX_OCCUR_LIMIT);
+- getSystemProperty(Limit.ELEMENT_ATTRIBUTE_LIMIT,
+- Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT);
++
++ for (Limit limit : Limit.values()) {
++ if (!getSystemProperty(limit, limit.systemProperty())) {
++ //if system property is not found, try the older form if any
++ for (NameMap nameMap : NameMap.values()) {
++ String oldName = nameMap.getOldName(limit.systemProperty());
++ if (oldName != null) {
++ getSystemProperty(limit, oldName);
++ }
++ }
++ }
++ }
++
+ }
+
+ /**
+ * Read from system properties, or those in jaxp.properties
+ *
+- * @param limit the type of the property
+- * @param property the property name
++ * @param property the type of the property
++ * @param sysPropertyName the name of system property
+ */
+- private void getSystemProperty(Limit limit, String property) {
++ private boolean getSystemProperty(Limit limit, String sysPropertyName) {
+ try {
+- String value = SecuritySupport.getSystemProperty(property);
++ String value = SecuritySupport.getSystemProperty(sysPropertyName);
+ if (value != null && !value.equals("")) {
+- limits[limit.ordinal()] = Integer.parseInt(value);
++ values[limit.ordinal()] = Integer.parseInt(value);
+ states[limit.ordinal()] = State.SYSTEMPROPERTY;
+- return;
++ return true;
+ }
+
+- value = SecuritySupport.readJAXPProperty(property);
++ value = SecuritySupport.readJAXPProperty(sysPropertyName);
+ if (value != null && !value.equals("")) {
+- limits[limit.ordinal()] = Integer.parseInt(value);
++ values[limit.ordinal()] = Integer.parseInt(value);
+ states[limit.ordinal()] = State.JAXPDOTPROPERTIES;
++ return true;
+ }
+ } catch (NumberFormatException e) {
+- //invalid setting ignored
++ //invalid setting
++ throw new NumberFormatException("Invalid setting for system property: " + limit.systemProperty());
+ }
++ return false;
+ }
+ }
+diff -r 3dc769c632a1 -r 0927621944cc drop_included/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java Tue Oct 29 07:18:24 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java Tue Oct 29 08:01:29 2013 +0000
+@@ -22,6 +22,9 @@
+ */
+ package com.sun.org.apache.xml.internal.utils;
+
++import com.sun.org.apache.xalan.internal.XalanConstants;
++import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
++
+ import java.util.HashMap;
+
+ import javax.xml.XMLConstants;
+@@ -64,6 +67,8 @@
+
+
+ private boolean _secureProcessing;
++
++ private XMLSecurityManager _xmlSecurityManager;
+ /**
+ * Hidden constructor
+ */
+@@ -156,6 +161,21 @@
+ }
+ }
+
++ try {
++ if (_xmlSecurityManager != null) {
++ for (XMLSecurityManager.Limit limit : XMLSecurityManager.Limit.values()) {
++ reader.setProperty(limit.apiProperty(),
++ _xmlSecurityManager.getLimitValueAsString(limit));
++ }
++ if (_xmlSecurityManager.printEntityCountInfo()) {
++ reader.setProperty(XalanConstants.JDK_ENTITY_COUNT_INFO, XalanConstants.JDK_YES);
++ }
++ }
++ } catch (SAXException se) {
++ System.err.println("Warning: " + reader.getClass().getName() + ": "
++ + se.getMessage());
++ }
++
+ return reader;
+ }
+
+@@ -168,6 +188,24 @@
+ }
+ }
+
++ /**
++ * Get property value
++ */
++ public Object getProperty(String name) {
++ if (name.equals(XalanConstants.SECURITY_MANAGER)) {
++ return _xmlSecurityManager;
++ }
++ return null;
++ }
++
++ /**
++ * Set property.
++ */
++ public void setProperty(String name, Object value) {
++ if (name.equals(XalanConstants.SECURITY_MANAGER)) {
++ _xmlSecurityManager = (XMLSecurityManager)value;
++ }
++ }
+ /**
+ * Mark the cached XMLReader as available. If the reader was not
+ * actually in the cache, do nothing.
diff --git a/java/openjdk6/files/icedtea/openjdk/8014534-better_profiling.patch b/java/openjdk6/files/icedtea/openjdk/8014534-better_profiling.patch
new file mode 100644
index 000000000000..c55741a63386
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014534-better_profiling.patch
@@ -0,0 +1,156 @@
+# HG changeset patch
+# User sjiang
+# Date 1374135176 -7200
+# Thu Jul 18 10:12:56 2013 +0200
+# Node ID 1e7a5ebc8013b812de73e452e809a3b545dd252f
+# Parent 698fe468e8b9385c2f74709dca823800b32e0b55
+8014534: Better profiling support
+Summary: Validation of parameters
+Reviewed-by: sspitsyn, skoivu, mchung
+
+diff -r 698fe468e8b9 -r 1e7a5ebc8013 src/share/classes/com/sun/demo/jvmti/hprof/Tracker.java
+--- jdk/src/share/classes/com/sun/demo/jvmti/hprof/Tracker.java Tue Oct 15 17:01:56 2013 +0100
++++ jdk/src/share/classes/com/sun/demo/jvmti/hprof/Tracker.java Thu Jul 18 10:12:56 2013 +0200
+@@ -53,7 +53,10 @@
+
+ public static void ObjectInit(Object obj)
+ {
+- if ( engaged != 0 ) {
++ if ( engaged != 0) {
++ if (obj == null) {
++ throw new IllegalArgumentException("Null object.");
++ }
+ nativeObjectInit(Thread.currentThread(), obj);
+ }
+ }
+@@ -66,7 +69,10 @@
+
+ public static void NewArray(Object obj)
+ {
+- if ( engaged != 0 ) {
++ if ( engaged != 0) {
++ if (obj == null) {
++ throw new IllegalArgumentException("Null object.");
++ }
+ nativeNewArray(Thread.currentThread(), obj);
+ }
+ }
+@@ -82,6 +88,14 @@
+ public static void CallSite(int cnum, int mnum)
+ {
+ if ( engaged != 0 ) {
++ if (cnum < 0) {
++ throw new IllegalArgumentException("Negative class index");
++ }
++
++ if (mnum < 0) {
++ throw new IllegalArgumentException("Negative method index");
++ }
++
+ nativeCallSite(Thread.currentThread(), cnum, mnum);
+ }
+ }
+@@ -95,6 +109,14 @@
+ public static void ReturnSite(int cnum, int mnum)
+ {
+ if ( engaged != 0 ) {
++ if (cnum < 0) {
++ throw new IllegalArgumentException("Negative class index");
++ }
++
++ if (mnum < 0) {
++ throw new IllegalArgumentException("Negative method index");
++ }
++
+ nativeReturnSite(Thread.currentThread(), cnum, mnum);
+ }
+ }
+diff -r 698fe468e8b9 -r 1e7a5ebc8013 src/share/demo/jvmti/hprof/hprof_class.c
+--- jdk/src/share/demo/jvmti/hprof/hprof_class.c Tue Oct 15 17:01:56 2013 +0100
++++ jdk/src/share/demo/jvmti/hprof/hprof_class.c Thu Jul 18 10:12:56 2013 +0200
+@@ -518,7 +518,12 @@
+ jmethodID method;
+
+ info = get_info(index);
+- HPROF_ASSERT(mnum < info->method_count);
++ if (mnum >= info->method_count) {
++ jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
++ (*env)->ThrowNew(env, newExcCls, "Illegal mnum");
++
++ return NULL;
++ }
+ method = info->method[mnum].method_id;
+ if ( method == NULL ) {
+ char * name;
+@@ -526,7 +531,12 @@
+ jclass clazz;
+
+ name = (char *)string_get(info->method[mnum].name_index);
+- HPROF_ASSERT(name!=NULL);
++ if (name==NULL) {
++ jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
++ (*env)->ThrowNew(env, newExcCls, "Name not found");
++
++ return NULL;
++ }
+ sig = (char *)string_get(info->method[mnum].sig_index);
+ HPROF_ASSERT(sig!=NULL);
+ clazz = class_get_class(env, index);
+diff -r 698fe468e8b9 -r 1e7a5ebc8013 src/share/demo/jvmti/hprof/hprof_event.c
+--- jdk/src/share/demo/jvmti/hprof/hprof_event.c Tue Oct 15 17:01:56 2013 +0100
++++ jdk/src/share/demo/jvmti/hprof/hprof_event.c Thu Jul 18 10:12:56 2013 +0200
+@@ -186,7 +186,12 @@
+
+ HPROF_ASSERT(env!=NULL);
+ HPROF_ASSERT(thread!=NULL);
+- HPROF_ASSERT(cnum!=0 && cnum!=gdata->tracker_cnum);
++ if (cnum == 0 || cnum == gdata->tracker_cnum) {
++ jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
++ (*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
++
++ return;
++ }
+
+ /* Prevent recursion into any BCI function for this thread (pstatus). */
+ if ( tls_get_tracker_status(env, thread, JNI_FALSE,
+@@ -195,8 +200,10 @@
+
+ (*pstatus) = 1;
+ method = class_get_methodID(env, cnum, mnum);
+- HPROF_ASSERT(method!=NULL);
+- tls_push_method(tls_index, method);
++ if (method != NULL) {
++ tls_push_method(tls_index, method);
++ }
++
+ (*pstatus) = 0;
+ }
+ }
+@@ -239,7 +246,13 @@
+
+ HPROF_ASSERT(env!=NULL);
+ HPROF_ASSERT(thread!=NULL);
+- HPROF_ASSERT(cnum!=0 && cnum!=gdata->tracker_cnum);
++
++ if (cnum == 0 || cnum == gdata->tracker_cnum) {
++ jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
++ (*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
++
++ return;
++ }
+
+ /* Prevent recursion into any BCI function for this thread (pstatus). */
+ if ( tls_get_tracker_status(env, thread, JNI_FALSE,
+@@ -248,8 +261,10 @@
+
+ (*pstatus) = 1;
+ method = class_get_methodID(env, cnum, mnum);
+- HPROF_ASSERT(method!=NULL);
+- tls_pop_method(tls_index, thread, method);
++ if (method != NULL) {
++ tls_pop_method(tls_index, thread, method);
++ }
++
+ (*pstatus) = 0;
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8014718-remove_logging_suntoolkit.patch b/java/openjdk6/files/icedtea/openjdk/8014718-remove_logging_suntoolkit.patch
new file mode 100644
index 000000000000..de29efa6522e
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014718-remove_logging_suntoolkit.patch
@@ -0,0 +1,115 @@
+# HG changeset patch
+# User leonidr
+# Date 1382726240 -3600
+# Fri Oct 25 19:37:20 2013 +0100
+# Node ID e7ed5dad88eefc49130ae02bcbf329d72f18f12e
+# Parent 47c881c5439a4542b19ab85f376e94fc2c0a5a57
+8014718: Netbeans IDE begins to throw a lot exceptions since 7u25 b10
+Summary: Removed logging from SunToolkit
+Reviewed-by: art, omajid
+
+diff -r 47c881c5439a -r e7ed5dad88ee src/share/classes/java/awt/Toolkit.java
+--- jdk/src/share/classes/java/awt/Toolkit.java Wed May 01 00:49:21 2013 +0200
++++ jdk/src/share/classes/java/awt/Toolkit.java Fri Oct 25 19:37:20 2013 +0100
+@@ -48,8 +48,6 @@
+ import java.io.FileInputStream;
+
+ import java.util.*;
+-import java.util.logging.*;
+-
+ import java.beans.PropertyChangeListener;
+ import java.beans.PropertyChangeSupport;
+ import sun.awt.AppContext;
+@@ -1922,7 +1920,7 @@
+ */
+ public abstract boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType);
+
+- private static final Logger log = Logger.getLogger("java.awt.Toolkit");
++ // 8014736: logging has been removed from Toolkit
+
+ private static final int LONG_BITS = 64;
+ private int[] calls = new int[LONG_BITS];
+@@ -2089,12 +2087,6 @@
+ }
+
+ synchronized int countAWTEventListeners(long eventMask) {
+- if (log.isLoggable(Level.FINE)) {
+- if (eventMask == 0) {
+- log.log(Level.FINE, "Assertion (eventMask != 0) failed");
+- }
+- }
+-
+ int ci = 0;
+ for (; eventMask != 0; eventMask >>>= 1, ci++) {
+ }
+diff -r 47c881c5439a -r e7ed5dad88ee src/share/classes/sun/awt/SunToolkit.java
+--- jdk/src/share/classes/sun/awt/SunToolkit.java Wed May 01 00:49:21 2013 +0200
++++ jdk/src/share/classes/sun/awt/SunToolkit.java Fri Oct 25 19:37:20 2013 +0100
+@@ -58,7 +58,7 @@
+ implements WindowClosingSupport, WindowClosingListener,
+ ComponentFactory, InputMethodSupport {
+
+- private static final Logger log = Logger.getLogger("sun.awt.SunToolkit");
++ // 8014736: logging has been removed from SunToolkit
+
+ /* Load debug settings for native code */
+ static {
+@@ -554,10 +554,6 @@
+ if (event == null) {
+ throw new NullPointerException();
+ }
+- AppContext eventContext = targetToAppContext(event.getSource());
+- if (eventContext != null && !eventContext.equals(appContext)) {
+- log.fine("Event posted on wrong app context : " + event);
+- }
+ PostEventQueue postEventQueue =
+ (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY);
+ if(postEventQueue != null) {
+@@ -938,10 +934,6 @@
+ //with scale factors x1, x3/4, x2/3, xN, x1/N.
+ Image im = i.next();
+ if (im == null) {
+- if (log.isLoggable(Level.FINER)) {
+- log.log(Level.FINER, "SunToolkit.getScaledIconImage: " +
+- "Skipping the image passed into Java because it's null.");
+- }
+ continue;
+ }
+ if (im instanceof ToolkitImage) {
+@@ -954,10 +946,6 @@
+ iw = im.getWidth(null);
+ ih = im.getHeight(null);
+ } catch (Exception e){
+- if (log.isLoggable(Level.FINER)) {
+- log.log(Level.FINER, "SunToolkit.getScaledIconImage: " +
+- "Perhaps the image passed into Java is broken. Skipping this icon.");
+- }
+ continue;
+ }
+ if (iw > 0 && ih > 0) {
+@@ -1029,14 +1017,6 @@
+ try {
+ int x = (width - bestWidth) / 2;
+ int y = (height - bestHeight) / 2;
+- if (log.isLoggable(Level.FINER)) {
+- log.log(Level.FINER, "WWindowPeer.getScaledIconData() result : " +
+- "w : " + width + " h : " + height +
+- " iW : " + bestImage.getWidth(null) + " iH : " + bestImage.getHeight(null) +
+- " sim : " + bestSimilarity + " sf : " + bestScaleFactor +
+- " adjW : " + bestWidth + " adjH : " + bestHeight +
+- " x : " + x + " y : " + y);
+- }
+ g.drawImage(bestImage, x, y, bestWidth, bestHeight, null);
+ } finally {
+ g.dispose();
+@@ -1047,10 +1027,6 @@
+ public static DataBufferInt getScaledIconData(java.util.List<Image> imageList, int width, int height) {
+ BufferedImage bimage = getScaledIconImage(imageList, width, height);
+ if (bimage == null) {
+- if (log.isLoggable(Level.FINER)) {
+- log.log(Level.FINER, "SunToolkit.getScaledIconData: " +
+- "Perhaps the image passed into Java is broken. Skipping this icon.");
+- }
+ return null;
+ }
+ Raster raster = bimage.getRaster();
diff --git a/java/openjdk6/files/icedtea/openjdk/8014745-logger_stack_walk_switch.patch b/java/openjdk6/files/icedtea/openjdk/8014745-logger_stack_walk_switch.patch
new file mode 100644
index 000000000000..06cc6e1d282c
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014745-logger_stack_walk_switch.patch
@@ -0,0 +1,205 @@
+# HG changeset patch
+# User mchung
+# Date 1368826191 25200
+# Fri May 17 14:29:51 2013 -0700
+# Node ID 0bf55b4c8a7bbea02a9d848b2a5451adbd6a6ac4
+# Parent 8733761ca20bb4e46405e274c514bda0e0616a21
+8014745: Provide a switch to allow stack walk search of resource bundle
+Reviewed-by: alanb, jgish
+
+diff -r 8733761ca20b -r 0bf55b4c8a7b make/java/java/mapfile-vers
+--- jdk/make/java/java/mapfile-vers Wed Jun 26 22:50:47 2013 -0500
++++ jdk/make/java/java/mapfile-vers Fri May 17 14:29:51 2013 -0700
+@@ -271,6 +271,7 @@
+ Java_sun_reflect_NativeConstructorAccessorImpl_newInstance0;
+ Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
+ Java_sun_reflect_Reflection_getCallerClass;
++ Java_sun_reflect_Reflection_getCallerClass0;
+ Java_sun_reflect_Reflection_getClassAccessFlags;
+ Java_sun_misc_Version_getJdkVersionInfo;
+ Java_sun_misc_Version_getJdkSpecialVersion;
+diff -r 8733761ca20b -r 0bf55b4c8a7b src/share/classes/java/util/logging/Logger.java
+--- jdk/src/share/classes/java/util/logging/Logger.java Wed Jun 26 22:50:47 2013 -0500
++++ jdk/src/share/classes/java/util/logging/Logger.java Fri May 17 14:29:51 2013 -0700
+@@ -303,8 +303,13 @@
+ // null, we assume it's a system logger and add it to the system context.
+ // These system loggers only set the resource bundle to the given
+ // resource bundle name (rather than the default system resource bundle).
+- private static class SystemLoggerHelper {
+- static boolean disableCallerCheck = getBooleanProperty("sun.util.logging.disableCallerCheck");
++ private static class LoggerHelper {
++ static boolean disableCallerCheck =
++ getBooleanProperty("sun.util.logging.disableCallerCheck");
++
++ // workaround to turn on the old behavior for resource bundle search
++ static boolean allowStackWalkSearch =
++ getBooleanProperty("jdk.logging.allowStackWalkSearch");
+ private static boolean getBooleanProperty(final String key) {
+ String s = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+@@ -318,7 +323,7 @@
+ private static Logger demandLogger(String name, String resourceBundleName, Class<?> caller) {
+ LogManager manager = LogManager.getLogManager();
+ SecurityManager sm = System.getSecurityManager();
+- if (sm != null && !SystemLoggerHelper.disableCallerCheck) {
++ if (sm != null && !LoggerHelper.disableCallerCheck) {
+ if (caller.getClassLoader() == null) {
+ return manager.demandSystemLogger(name, resourceBundleName);
+ }
+@@ -1407,25 +1412,61 @@
+ if (useCallersClassLoader) {
+ // Try with the caller's ClassLoader
+ ClassLoader callersClassLoader = getCallersClassLoader();
++ if (callersClassLoader != null && callersClassLoader != cl) {
++ try {
++ catalog = ResourceBundle.getBundle(name, currentLocale,
++ callersClassLoader);
++ catalogName = name;
++ catalogLocale = currentLocale;
++ return catalog;
++ } catch (MissingResourceException ex) {
++ }
++ }
++ }
+
+- if (callersClassLoader == null || callersClassLoader == cl) {
+- return null;
+- }
+-
+- try {
+- catalog = ResourceBundle.getBundle(name, currentLocale,
+- callersClassLoader);
+- catalogName = name;
+- catalogLocale = currentLocale;
+- return catalog;
+- } catch (MissingResourceException ex) {
+- return null; // no luck
+- }
++ // If -Djdk.logging.allowStackWalkSearch=true is set,
++ // does stack walk to search for the resource bundle
++ if (LoggerHelper.allowStackWalkSearch) {
++ return findResourceBundleFromStack(name, currentLocale, cl);
+ } else {
+ return null;
+ }
+ }
+
++ /**
++ * This method will fail when running with a VM that enforces caller-sensitive
++ * methods and only allows to get the immediate caller.
++ */
++ @CallerSensitive
++ private synchronized ResourceBundle findResourceBundleFromStack(String name,
++ Locale locale,
++ ClassLoader cl)
++ {
++ for (int ix = 0; ; ix++) {
++ Class<?> clz = sun.reflect.Reflection.getCallerClass(ix);
++ if (clz == null) {
++ break;
++ }
++ ClassLoader cl2 = clz.getClassLoader();
++ if (cl2 == null) {
++ cl2 = ClassLoader.getSystemClassLoader();
++ }
++ if (cl == cl2) {
++ // We've already checked this classloader.
++ continue;
++ }
++ cl = cl2;
++ try {
++ catalog = ResourceBundle.getBundle(name, locale, cl);
++ catalogName = name;
++ catalogLocale = locale;
++ return catalog;
++ } catch (MissingResourceException ex) {
++ }
++ }
++ return null;
++ }
++
+ // Private utility method to initialize our one entry
+ // resource bundle name cache and the callers ClassLoader
+ // Note: for consistency reasons, we are careful to check
+diff -r 8733761ca20b -r 0bf55b4c8a7b src/share/classes/sun/reflect/Reflection.java
+--- jdk/src/share/classes/sun/reflect/Reflection.java Wed Jun 26 22:50:47 2013 -0500
++++ jdk/src/share/classes/sun/reflect/Reflection.java Fri May 17 14:29:51 2013 -0700
+@@ -58,6 +58,21 @@
+ @CallerSensitive
+ public static native Class getCallerClass();
+
++ /**
++ * @deprecated No replacement. This method will be removed in the next
++ * JDK 7 update release.
++ */
++ @Deprecated
++ @CallerSensitive
++ public static Class getCallerClass(int depth) {
++ return getCallerClass0(depth);
++ }
++
++ // If the VM enforces getting caller class with @CallerSensitive,
++ // this will fail anyway.
++ @CallerSensitive
++ private static native Class getCallerClass0(int depth);
++
+ /** Retrieves the access flags written to the class file. For
+ inner classes these flags may differ from those returned by
+ Class.getModifiers(), which searches the InnerClasses
+diff -r 8733761ca20b -r 0bf55b4c8a7b src/share/native/sun/reflect/Reflection.c
+--- jdk/src/share/native/sun/reflect/Reflection.c Wed Jun 26 22:50:47 2013 -0500
++++ jdk/src/share/native/sun/reflect/Reflection.c Fri May 17 14:29:51 2013 -0700
+@@ -34,6 +34,12 @@
+ return JVM_GetCallerClass(env, 2);
+ }
+
++JNIEXPORT jclass JNICALL Java_sun_reflect_Reflection_getCallerClass0
++(JNIEnv *env, jclass unused, jint depth)
++{
++ return JVM_GetCallerClass(env, depth);
++}
++
+ JNIEXPORT jint JNICALL Java_sun_reflect_Reflection_getClassAccessFlags
+ (JNIEnv *env, jclass unused, jclass cls)
+ {
+diff -r 8733761ca20b -r 0bf55b4c8a7b test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java
+--- jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Wed Jun 26 22:50:47 2013 -0500
++++ jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Fri May 17 14:29:51 2013 -0700
+@@ -28,6 +28,7 @@
+ * @author Jim Gish
+ * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp1 LoadItUp2 TwiceIndirectlyLoadABundle LoadItUp2Invoker
+ * @run main/othervm ResourceBundleSearchTest
++ * @run main/othervm -Djdk.logging.allowStackWalkSearch=true ResourceBundleSearchTest
+ */
+ import java.net.URL;
+ import java.net.URLClassLoader;
+@@ -79,7 +80,15 @@
+
+ // Test 1 - can we find a Logger bundle from doing a stack search?
+ // We shouldn't be able to
+- assertFalse(testGetBundleFromStackSearch(), "1-testGetBundleFromStackSearch");
++ // unless -Djdk.logging.allowStackWalkSearch=true is set
++
++ boolean allowStackWalkSearch = Boolean.getBoolean("jdk.logging.allowStackWalkSearch");
++ if (allowStackWalkSearch) {
++ assertTrue(testGetBundleFromStackSearch(), "1-testGetBundleFromStackSearch");
++ } else {
++ // default behavior
++ assertFalse(testGetBundleFromStackSearch(), "1-testGetBundleFromStackSearch");
++ }
+
+ // Test 2 - can we find a Logger bundle off of the Thread context class
+ // loader? We should be able to.
+@@ -111,8 +120,10 @@
+ // Test 6 - first call getLogger("myLogger").
+ // Then call getLogger("myLogger","bundleName") from a different ClassLoader
+ // Make sure we find the bundle
+- assertTrue(testGetBundleFromSecondCallersClassLoader(),
+- "6-testGetBundleFromSecondCallersClassLoader");
++ if (!allowStackWalkSearch) {
++ assertTrue(testGetBundleFromSecondCallersClassLoader(),
++ "6-testGetBundleFromSecondCallersClassLoader");
++ }
+
+ report();
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8014987-augment_serialization.patch b/java/openjdk6/files/icedtea/openjdk/8014987-augment_serialization.patch
new file mode 100644
index 000000000000..f8f53a9e9643
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8014987-augment_serialization.patch
@@ -0,0 +1,100 @@
+# HG changeset patch
+# User smarks
+# Date 1381854512 -3600
+# Tue Oct 15 17:28:32 2013 +0100
+# Node ID a1bc92467cc07e1cb3c93d0b3b629eda4c45238f
+# Parent 1e7a5ebc8013b812de73e452e809a3b545dd252f
+8014987: Augment serialization handling
+Reviewed-by: alanb, coffeys, skoivu
+
+diff -r 1e7a5ebc8013 -r a1bc92467cc0 src/share/classes/java/io/ObjectInputStream.java
+--- jdk/src/share/classes/java/io/ObjectInputStream.java Thu Jul 18 10:12:56 2013 +0200
++++ jdk/src/share/classes/java/io/ObjectInputStream.java Tue Oct 15 17:28:32 2013 +0100
+@@ -489,11 +489,12 @@
+ public void defaultReadObject()
+ throws IOException, ClassNotFoundException
+ {
+- if (curContext == null) {
++ SerialCallbackContext ctx = curContext;
++ if (ctx == null) {
+ throw new NotActiveException("not in call to readObject");
+ }
+- Object curObj = curContext.getObj();
+- ObjectStreamClass curDesc = curContext.getDesc();
++ Object curObj = ctx.getObj();
++ ObjectStreamClass curDesc = ctx.getDesc();
+ bin.setBlockDataMode(false);
+ defaultReadFields(curObj, curDesc);
+ bin.setBlockDataMode(true);
+@@ -527,11 +528,12 @@
+ public ObjectInputStream.GetField readFields()
+ throws IOException, ClassNotFoundException
+ {
+- if (curContext == null) {
++ SerialCallbackContext ctx = curContext;
++ if (ctx == null) {
+ throw new NotActiveException("not in call to readObject");
+ }
+- Object curObj = curContext.getObj();
+- ObjectStreamClass curDesc = curContext.getDesc();
++ Object curObj = ctx.getObj();
++ ObjectStreamClass curDesc = ctx.getDesc();
+ bin.setBlockDataMode(false);
+ GetFieldImpl getField = new GetFieldImpl(curDesc);
+ getField.readFields();
+@@ -1964,7 +1966,6 @@
+ private void defaultReadFields(Object obj, ObjectStreamClass desc)
+ throws IOException
+ {
+- // REMIND: is isInstance check necessary?
+ Class cl = desc.forClass();
+ if (cl != null && obj != null && !cl.isInstance(obj)) {
+ throw new ClassCastException();
+diff -r 1e7a5ebc8013 -r a1bc92467cc0 src/share/classes/java/io/ObjectOutputStream.java
+--- jdk/src/share/classes/java/io/ObjectOutputStream.java Thu Jul 18 10:12:56 2013 +0200
++++ jdk/src/share/classes/java/io/ObjectOutputStream.java Tue Oct 15 17:28:32 2013 +0100
+@@ -430,11 +430,12 @@
+ * <code>OutputStream</code>
+ */
+ public void defaultWriteObject() throws IOException {
+- if ( curContext == null ) {
++ SerialCallbackContext ctx = curContext;
++ if (ctx == null) {
+ throw new NotActiveException("not in call to writeObject");
+ }
+- Object curObj = curContext.getObj();
+- ObjectStreamClass curDesc = curContext.getDesc();
++ Object curObj = ctx.getObj();
++ ObjectStreamClass curDesc = ctx.getDesc();
+ bout.setBlockDataMode(false);
+ defaultWriteFields(curObj, curDesc);
+ bout.setBlockDataMode(true);
+@@ -452,11 +453,12 @@
+ */
+ public ObjectOutputStream.PutField putFields() throws IOException {
+ if (curPut == null) {
+- if (curContext == null) {
++ SerialCallbackContext ctx = curContext;
++ if (ctx == null) {
+ throw new NotActiveException("not in call to writeObject");
+ }
+- Object curObj = curContext.getObj();
+- ObjectStreamClass curDesc = curContext.getDesc();
++ Object curObj = ctx.getObj();
++ ObjectStreamClass curDesc = ctx.getDesc();
+ curPut = new PutFieldImpl(curDesc);
+ }
+ return curPut;
+@@ -1516,7 +1518,11 @@
+ private void defaultWriteFields(Object obj, ObjectStreamClass desc)
+ throws IOException
+ {
+- // REMIND: perform conservative isInstance check here?
++ Class<?> cl = desc.forClass();
++ if (cl != null && obj != null && !cl.isInstance(obj)) {
++ throw new ClassCastException();
++ }
++
+ desc.checkDefaultSerialize();
+
+ int primDataSize = desc.getPrimDataSize();
diff --git a/java/openjdk6/files/icedtea/openjdk/8015144-performance_regression.patch b/java/openjdk6/files/icedtea/openjdk/8015144-performance_regression.patch
new file mode 100644
index 000000000000..2f13ff3d3131
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8015144-performance_regression.patch
@@ -0,0 +1,273 @@
+# HG changeset patch
+# User prr
+# Date 1383010378 0
+# Tue Oct 29 01:32:58 2013 +0000
+# Node ID bac5d0b011562017738501f02f7db4f39522a62e
+# Parent 35c5b3f404aac29ec5cccaeb32106af47546b6db
+8015144: Performance regression in ICU OpenType Layout library
+Reviewed-by: srl, jgodinez
+
+diff -r 35c5b3f404aa -r bac5d0b01156 src/share/native/sun/font/layout/GlyphIterator.cpp
+--- jdk/src/share/native/sun/font/layout/GlyphIterator.cpp Wed Jun 05 18:39:44 2013 +0100
++++ jdk/src/share/native/sun/font/layout/GlyphIterator.cpp Tue Oct 29 01:32:58 2013 +0000
+@@ -66,6 +66,7 @@
+ nextLimit = -1;
+ prevLimit = glyphCount;
+ }
++ filterResetCache();
+ }
+
+ GlyphIterator::GlyphIterator(GlyphIterator &that)
+@@ -84,6 +85,7 @@
+ glyphGroup = that.glyphGroup;
+ glyphClassDefinitionTable = that.glyphClassDefinitionTable;
+ markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
++ filterResetCache();
+ }
+
+ GlyphIterator::GlyphIterator(GlyphIterator &that, FeatureMask newFeatureMask)
+@@ -102,6 +104,7 @@
+ glyphGroup = 0;
+ glyphClassDefinitionTable = that.glyphClassDefinitionTable;
+ markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
++ filterResetCache();
+ }
+
+ GlyphIterator::GlyphIterator(GlyphIterator &that, le_uint16 newLookupFlags)
+@@ -120,6 +123,7 @@
+ glyphGroup = that.glyphGroup;
+ glyphClassDefinitionTable = that.glyphClassDefinitionTable;
+ markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
++ filterResetCache();
+ }
+
+ GlyphIterator::~GlyphIterator()
+@@ -133,6 +137,7 @@
+ featureMask = newFeatureMask;
+ glyphGroup = 0;
+ lookupFlags = newLookupFlags;
++ filterResetCache();
+ }
+
+ LEGlyphID *GlyphIterator::insertGlyphs(le_int32 count, LEErrorCode& success)
+@@ -381,53 +386,68 @@
+ glyphPositionAdjustments->setCursiveGlyph(position, baselineIsLogicalEnd());
+ }
+
+-le_bool GlyphIterator::filterGlyph(le_uint32 index) const
+-{
+- LEErrorCode success = LE_NO_ERROR;
+- LEGlyphID glyphID = glyphStorage[index];
+- le_int32 glyphClass = gcdNoGlyphClass;
+-
+- if (LE_GET_GLYPH(glyphID) >= 0xFFFE) {
+- return TRUE;
++void GlyphIterator::filterResetCache(void) {
++ filterCacheValid = FALSE;
+ }
+
++le_bool GlyphIterator::filterGlyph(le_uint32 index)
++{
++ LEGlyphID glyphID = glyphStorage[index];
++
++ if (!filterCacheValid || filterCache.id != glyphID) {
++ filterCache.id = glyphID;
++
++ le_bool &filterResult = filterCache.result; // NB: Making this a reference to accept the updated value, in case
++ // we want more fancy cacheing in the future.
++ if (LE_GET_GLYPH(glyphID) >= 0xFFFE) {
++ filterResult = TRUE;
++ } else {
++ LEErrorCode success = LE_NO_ERROR;
++ le_int32 glyphClass = gcdNoGlyphClass;
+ if (glyphClassDefinitionTable.isValid()) {
+ glyphClass = glyphClassDefinitionTable->getGlyphClass(glyphClassDefinitionTable, glyphID, success);
+ }
+-
+- switch (glyphClass)
+- {
++ switch (glyphClass) {
+ case gcdNoGlyphClass:
+- return FALSE;
++ filterResult = FALSE;
++ break;
+
+ case gcdSimpleGlyph:
+- return (lookupFlags & lfIgnoreBaseGlyphs) != 0;
++ filterResult = (lookupFlags & lfIgnoreBaseGlyphs) != 0;
++ break;
+
+ case gcdLigatureGlyph:
+- return (lookupFlags & lfIgnoreLigatures) != 0;
++ filterResult = (lookupFlags & lfIgnoreLigatures) != 0;
++ break;
+
+ case gcdMarkGlyph:
+- {
+ if ((lookupFlags & lfIgnoreMarks) != 0) {
+- return TRUE;
+- }
+-
++ filterResult = TRUE;
++ } else {
+ le_uint16 markAttachType = (lookupFlags & lfMarkAttachTypeMask) >> lfMarkAttachTypeShift;
+
+ if ((markAttachType != 0) && (markAttachClassDefinitionTable.isValid())) {
+- return markAttachClassDefinitionTable
+- -> getGlyphClass(markAttachClassDefinitionTable, glyphID, success) != markAttachType;
++ filterResult = (markAttachClassDefinitionTable
++ -> getGlyphClass(markAttachClassDefinitionTable, glyphID, success) != markAttachType);
++ } else {
++ filterResult = FALSE;
++ }
++ }
++ break;
++
++ case gcdComponentGlyph:
++ filterResult = ((lookupFlags & lfIgnoreBaseGlyphs) != 0);
++ break;
++
++ default:
++ filterResult = FALSE;
++ break;
++ }
++ }
++ filterCacheValid = TRUE;
+ }
+
+- return FALSE;
+- }
+-
+- case gcdComponentGlyph:
+- return (lookupFlags & lfIgnoreBaseGlyphs) != 0;
+-
+- default:
+- return FALSE;
+- }
++ return filterCache.result;
+ }
+
+ le_bool GlyphIterator::hasFeatureTag(le_bool matchGroup) const
+diff -r 35c5b3f404aa -r bac5d0b01156 src/share/native/sun/font/layout/GlyphIterator.h
+--- jdk/src/share/native/sun/font/layout/GlyphIterator.h Wed Jun 05 18:39:44 2013 +0100
++++ jdk/src/share/native/sun/font/layout/GlyphIterator.h Tue Oct 29 01:32:58 2013 +0000
+@@ -98,7 +98,7 @@
+ le_int32 applyInsertions();
+
+ private:
+- le_bool filterGlyph(le_uint32 index) const;
++ le_bool filterGlyph(le_uint32 index);
+ le_bool hasFeatureTag(le_bool matchGroup) const;
+ le_bool nextInternal(le_uint32 delta = 1);
+ le_bool prevInternal(le_uint32 delta = 1);
+@@ -121,6 +121,14 @@
+ LEReferenceTo<MarkAttachClassDefinitionTable> markAttachClassDefinitionTable;
+
+ GlyphIterator &operator=(const GlyphIterator &other); // forbid copying of this class
++
++ struct {
++ LEGlyphID id;
++ le_bool result;
++ } filterCache;
++ le_bool filterCacheValid;
++
++ void filterResetCache(void);
+ };
+
+ U_NAMESPACE_END
+diff -r 35c5b3f404aa -r bac5d0b01156 src/share/native/sun/font/layout/LETableReference.h
+--- jdk/src/share/native/sun/font/layout/LETableReference.h Wed Jun 05 18:39:44 2013 +0100
++++ jdk/src/share/native/sun/font/layout/LETableReference.h Tue Oct 29 01:32:58 2013 +0000
+@@ -431,7 +431,7 @@
+ * @param success error status
+ * @param atPtr location of reference - if NULL, will be at offset zero (i.e. downcast of parent). Otherwise must be a pointer within parent's bounds.
+ */
+- LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr)
++ inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr)
+ : LETableReference(parent, parent.ptrToOffset(atPtr, success), LE_UINTPTR_MAX, success) {
+ verifyLength(parent.ptrToOffset(atPtr,success), LETableVarSizer<T>::getSize(), success);
+ if(LE_FAILURE(success)) clear();
+@@ -439,31 +439,31 @@
+ /**
+ * ptr plus offset
+ */
+- LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr, size_t offset)
++ inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, const void* atPtr, size_t offset)
+ : LETableReference(parent, parent.ptrToOffset(atPtr, success)+offset, LE_UINTPTR_MAX, success) {
+ verifyLength(0, LETableVarSizer<T>::getSize(), success);
+ if(LE_FAILURE(success)) clear();
+ }
+- LEReferenceTo(const LETableReference &parent, LEErrorCode &success, size_t offset)
++ inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success, size_t offset)
+ : LETableReference(parent, offset, LE_UINTPTR_MAX, success) {
+ verifyLength(0, LETableVarSizer<T>::getSize(), success);
+ if(LE_FAILURE(success)) clear();
+ }
+- LEReferenceTo(const LETableReference &parent, LEErrorCode &success)
++ inline LEReferenceTo(const LETableReference &parent, LEErrorCode &success)
+ : LETableReference(parent, 0, LE_UINTPTR_MAX, success) {
+ verifyLength(0, LETableVarSizer<T>::getSize(), success);
+ if(LE_FAILURE(success)) clear();
+ }
+- LEReferenceTo(const LEFontInstance *font, LETag tableTag, LEErrorCode &success)
++ inline LEReferenceTo(const LEFontInstance *font, LETag tableTag, LEErrorCode &success)
+ : LETableReference(font, tableTag, success) {
+ verifyLength(0, LETableVarSizer<T>::getSize(), success);
+ if(LE_FAILURE(success)) clear();
+ }
+- LEReferenceTo(const le_uint8 *data, size_t length = LE_UINTPTR_MAX) : LETableReference(data, length) {}
+- LEReferenceTo(const T *data, size_t length = LE_UINTPTR_MAX) : LETableReference((const le_uint8*)data, length) {}
+- LEReferenceTo() : LETableReference(NULL) {}
++ inline LEReferenceTo(const le_uint8 *data, size_t length = LE_UINTPTR_MAX) : LETableReference(data, length) {}
++ inline LEReferenceTo(const T *data, size_t length = LE_UINTPTR_MAX) : LETableReference((const le_uint8*)data, length) {}
++ inline LEReferenceTo() : LETableReference(NULL) {}
+
+- LEReferenceTo<T>& operator=(const T* other) {
++ inline LEReferenceTo<T>& operator=(const T* other) {
+ setRaw(other);
+ return *this;
+ }
+diff -r 35c5b3f404aa -r bac5d0b01156 src/share/native/sun/font/layout/OpenTypeUtilities.cpp
+--- jdk/src/share/native/sun/font/layout/OpenTypeUtilities.cpp Wed Jun 05 18:39:44 2013 +0100
++++ jdk/src/share/native/sun/font/layout/OpenTypeUtilities.cpp Tue Oct 29 01:32:58 2013 +0000
+@@ -79,6 +79,7 @@
+
+ Offset OpenTypeUtilities::getTagOffset(LETag tag, const LEReferenceToArrayOf<TagAndOffsetRecord> &records, LEErrorCode &success)
+ {
++ const TagAndOffsetRecord *r0 = (const TagAndOffsetRecord*)records.getAlias();
+ if(LE_FAILURE(success)) return 0;
+
+ le_uint32 recordCount = records.getCount();
+@@ -89,17 +90,17 @@
+ le_int32 index = 0;
+
+ {
+- const ATag &aTag = records.getAlias(extra,success)->tag;
++ const ATag &aTag = (r0+extra)->tag;
+ if (SWAPT(aTag) <= tag) {
+ index = extra;
+ }
+ }
+
+- while (probe > (1 << 0) && LE_SUCCESS(success)) {
++ while (probe > (1 << 0)) {
+ probe >>= 1;
+
+ {
+- const ATag &aTag = records.getAlias(index+probe,success)->tag;
++ const ATag &aTag = (r0+index+probe)->tag;
+ if (SWAPT(aTag) <= tag) {
+ index += probe;
+ }
+@@ -107,9 +108,9 @@
+ }
+
+ {
+- const ATag &aTag = records.getAlias(index,success)->tag;
++ const ATag &aTag = (r0+index)->tag;
+ if (SWAPT(aTag) == tag) {
+- return SWAPW(records.getAlias(index,success)->offset);
++ return SWAPW((r0+index)->offset);
+ }
+ }
+
diff --git a/java/openjdk6/files/icedtea/openjdk/8015614-update_build.patch b/java/openjdk6/files/icedtea/openjdk/8015614-update_build.patch
new file mode 100644
index 000000000000..72ff7b6a37d9
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8015614-update_build.patch
@@ -0,0 +1,60 @@
+# HG changeset patch
+# User erikj
+# Date 1381419677 -3600
+# Thu Oct 10 16:41:17 2013 +0100
+# Node ID 918a90950fa69e5247e3af2599d2e7674d64e3d6
+# Parent d0b5dc55e72cde11331399cbb960458b8f45ea4a
+8015614: Update build settings
+Reviewed-by: tbell, dholmes, ahgross
+
+diff -r d0b5dc55e72c -r 918a90950fa6 make/windows/makefiles/compile.make
+--- hotspot/make/windows/makefiles/compile.make Tue Sep 17 12:04:11 2013 +0200
++++ hotspot/make/windows/makefiles/compile.make Thu Oct 10 16:41:17 2013 +0100
+@@ -140,6 +140,7 @@
+ !if "$(MSC_VER)" == "1600"
+ COMPILER_NAME=VS2010
+ !endif
++SAFESEH_FLAG = /SAFESEH
+ !endif
+
+ # By default, we do not want to use the debug version of the msvcrt.dll file
+@@ -170,6 +171,7 @@
+ PRODUCT_OPT_OPTION = /O2 /Oy-
+ FASTDEBUG_OPT_OPTION = /O2 /Oy-
+ DEBUG_OPT_OPTION = /Od
++SAFESEH_FLAG = /SAFESEH
+ !endif
+
+ !if "$(COMPILER_NAME)" == "VS2005"
+@@ -186,6 +188,7 @@
+ # Manifest Tool - used in VS2005 and later to adjust manifests stored
+ # as resources inside build artifacts.
+ MT=mt.exe
++SAFESEH_FLAG = /SAFESEH
+ !endif
+
+ !if "$(COMPILER_NAME)" == "VS2008"
+@@ -209,8 +212,8 @@
+ # as resources inside build artifacts.
+ MT=mt.exe
+ !if "$(BUILDARCH)" == "i486"
+-LD_FLAGS = /SAFESEH $(LD_FLAGS)
+-!endif
++LD_FLAGS = $(SAFESEH_FLAG) $(LD_FLAGS)
++SAFESEH_FLAG = /SAFESEH
+ !endif
+
+ # Compile for space above time.
+diff -r d0b5dc55e72c -r 918a90950fa6 make/windows/makefiles/sa.make
+--- hotspot/make/windows/makefiles/sa.make Tue Sep 17 12:04:11 2013 +0200
++++ hotspot/make/windows/makefiles/sa.make Thu Oct 10 16:41:17 2013 +0100
+@@ -107,6 +107,9 @@
+ !if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
+ SA_LFLAGS = $(SA_LFLAGS) /map /debug
+ !endif
++!if "$(BUILDARCH)" == "i486"
++SA_LFLAGS = $(SAFESEH_FLAG) $(SA_LFLAGS)
++!endif
+
+ # Note that we do not keep sawindbj.obj around as it would then
+ # get included in the dumpbin command in build_vm_def.sh
diff --git a/java/openjdk6/files/icedtea/openjdk/8015731-auth_improvements.patch b/java/openjdk6/files/icedtea/openjdk/8015731-auth_improvements.patch
new file mode 100644
index 000000000000..0e75d3b06bd2
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8015731-auth_improvements.patch
@@ -0,0 +1,28 @@
+# HG changeset patch
+# User weijun
+# Date 1371090681 -28800
+# Thu Jun 13 10:31:21 2013 +0800
+# Node ID e10e9bfb11b073ee1c108e7a51078d3ead7a2d72
+# Parent a1bc92467cc07e1cb3c93d0b3b629eda4c45238f
+8015731: Subject java.security.auth.subject to improvements
+Reviewed-by: skoivu, mullan
+
+diff -r a1bc92467cc0 -r e10e9bfb11b0 src/share/classes/javax/security/auth/Subject.java
+--- jdk/src/share/classes/javax/security/auth/Subject.java Tue Oct 15 17:28:32 2013 +0100
++++ jdk/src/share/classes/javax/security/auth/Subject.java Thu Jun 13 10:31:21 2013 +0800
+@@ -1305,8 +1305,14 @@
+ {
+ ObjectInputStream.GetField fields = ois.readFields();
+ subject = (Subject) fields.get("this$0", null);
+- elements = (LinkedList<E>) fields.get("elements", null);
+ which = fields.get("which", 0);
++
++ LinkedList<E> tmp = (LinkedList<E>) fields.get("elements", null);
++ if (tmp.getClass() != LinkedList.class) {
++ elements = new LinkedList<E>(tmp);
++ } else {
++ elements = tmp;
++ }
+ }
+ }
+
diff --git a/java/openjdk6/files/icedtea/openjdk/8015743-address_internet_addresses.patch b/java/openjdk6/files/icedtea/openjdk/8015743-address_internet_addresses.patch
new file mode 100644
index 000000000000..c44cea89db82
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8015743-address_internet_addresses.patch
@@ -0,0 +1,1290 @@
+# HG changeset patch
+# User michaelm
+# Date 1381868930 -3600
+# Tue Oct 15 21:28:50 2013 +0100
+# Node ID 96aee3742c52d2d1a83a3db0be2c14892a511c67
+# Parent e10e9bfb11b073ee1c108e7a51078d3ead7a2d72
+8015743: Address internet addresses
+Summary: moved Inet6Address fields to holder class
+Reviewed-by: chegar, alanb, skoivu, khazra
+
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/share/classes/java/net/Inet6Address.java
+--- jdk/src/share/classes/java/net/Inet6Address.java Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/share/classes/java/net/Inet6Address.java Tue Oct 15 21:28:50 2013 +0100
+@@ -27,6 +27,8 @@
+
+ import java.security.AccessController;
+ import java.io.ObjectInputStream;
++import java.io.ObjectOutputStream;
++import java.io.ObjectStreamField;
+ import java.io.IOException;
+ import java.io.ObjectStreamException;
+ import java.io.InvalidObjectException;
+@@ -174,36 +176,196 @@
+ */
+ private transient int cached_scope_id = 0;
+
+- /**
+- * Holds a 128-bit (16 bytes) IPv6 address.
+- *
+- * @serial
+- */
+- byte[] ipaddress;
++ private class Inet6AddressHolder {
+
+- /**
+- * scope_id. The scope specified when the object is created. If the object is created
+- * with an interface name, then the scope_id is not determined until the time it is needed.
+- */
+- private int scope_id = 0;
++ private Inet6AddressHolder() {
++ ipaddress = new byte[INADDRSZ];
++ }
+
+- /**
+- * This will be set to true when the scope_id field contains a valid
+- * integer scope_id.
+- */
+- private boolean scope_id_set = false;
++ private Inet6AddressHolder(
++ byte[] ipaddress, int scope_id, boolean scope_id_set,
++ NetworkInterface ifname, boolean scope_ifname_set)
++ {
++ this.ipaddress = ipaddress;
++ this.scope_id = scope_id;
++ this.scope_id_set = scope_id_set;
++ this.scope_ifname_set = scope_ifname_set;
++ this.scope_ifname = ifname;
++ }
+
+- /**
+- * scoped interface. scope_id is derived from this as the scope_id of the first
+- * address whose scope is the same as this address for the named interface.
+- */
+- private transient NetworkInterface scope_ifname = null;
++ /**
++ * Holds a 128-bit (16 bytes) IPv6 address.
++ */
++ byte[] ipaddress;
+
+- /**
+- * set if the object is constructed with a scoped interface instead of a
+- * numeric scope id.
+- */
+- private boolean scope_ifname_set = false;
++ /**
++ * scope_id. The scope specified when the object is created. If the object is created
++ * with an interface name, then the scope_id is not determined until the time it is needed.
++ */
++ int scope_id = 0;
++
++ /**
++ * This will be set to true when the scope_id field contains a valid
++ * integer scope_id.
++ */
++ boolean scope_id_set = false;
++
++ /**
++ * scoped interface. scope_id is derived from this as the scope_id of the first
++ * address whose scope is the same as this address for the named interface.
++ */
++ NetworkInterface scope_ifname = null;
++
++ /**
++ * set if the object is constructed with a scoped interface instead of a
++ * numeric scope id.
++ */
++ boolean scope_ifname_set = false;
++
++ void setAddr(byte addr[]) {
++ if (addr.length == INADDRSZ) { // normal IPv6 address
++ System.arraycopy(addr, 0, ipaddress, 0, INADDRSZ);
++ }
++ }
++
++ void init(byte addr[], int scope_id) {
++ setAddr(addr);
++
++ if (scope_id >= 0) {
++ this.scope_id = scope_id;
++ this.scope_id_set = true;
++ }
++ }
++
++ void init(byte addr[], NetworkInterface nif)
++ throws UnknownHostException
++ {
++ setAddr(addr);
++
++ if (nif != null) {
++ this.scope_id = deriveNumericScope(ipaddress, nif);
++ this.scope_id_set = true;
++ this.scope_ifname = nif;
++ this.scope_ifname_set = true;
++ }
++ }
++
++ String getHostAddress() {
++ String s = numericToTextFormat(ipaddress);
++ if (scope_ifname_set) { /* must check this first */
++ s = s + "%" + scope_ifname.getName();
++ } else if (scope_id_set) {
++ s = s + "%" + scope_id;
++ }
++ return s;
++ }
++
++ public boolean equals(Object o) {
++ if (! (o instanceof Inet6AddressHolder)) {
++ return false;
++ }
++ Inet6AddressHolder that = (Inet6AddressHolder)o;
++
++ for (int i = 0; i < INADDRSZ; i++) {
++ if (this.ipaddress[i] != that.ipaddress[i])
++ return false;
++ }
++
++ return true;
++ }
++
++ public int hashCode() {
++ if (ipaddress != null) {
++
++ int hash = 0;
++ int i=0;
++ while (i<INADDRSZ) {
++ int j=0;
++ int component=0;
++ while (j<4 && i<INADDRSZ) {
++ component = (component << 8) + ipaddress[i];
++ j++;
++ i++;
++ }
++ hash += component;
++ }
++ return hash;
++
++ } else {
++ return 0;
++ }
++ }
++
++ boolean isIPv4CompatibleAddress() {
++ if ((ipaddress[0] == 0x00) && (ipaddress[1] == 0x00) &&
++ (ipaddress[2] == 0x00) && (ipaddress[3] == 0x00) &&
++ (ipaddress[4] == 0x00) && (ipaddress[5] == 0x00) &&
++ (ipaddress[6] == 0x00) && (ipaddress[7] == 0x00) &&
++ (ipaddress[8] == 0x00) && (ipaddress[9] == 0x00) &&
++ (ipaddress[10] == 0x00) && (ipaddress[11] == 0x00)) {
++ return true;
++ }
++ return false;
++ }
++
++ boolean isMulticastAddress() {
++ return ((ipaddress[0] & 0xff) == 0xff);
++ }
++
++ boolean isAnyLocalAddress() {
++ byte test = 0x00;
++ for (int i = 0; i < INADDRSZ; i++) {
++ test |= ipaddress[i];
++ }
++ return (test == 0x00);
++ }
++
++ boolean isLoopbackAddress() {
++ byte test = 0x00;
++ for (int i = 0; i < 15; i++) {
++ test |= ipaddress[i];
++ }
++ return (test == 0x00) && (ipaddress[15] == 0x01);
++ }
++
++ boolean isLinkLocalAddress() {
++ return ((ipaddress[0] & 0xff) == 0xfe
++ && (ipaddress[1] & 0xc0) == 0x80);
++ }
++
++
++ boolean isSiteLocalAddress() {
++ return ((ipaddress[0] & 0xff) == 0xfe
++ && (ipaddress[1] & 0xc0) == 0xc0);
++ }
++
++ boolean isMCGlobal() {
++ return ((ipaddress[0] & 0xff) == 0xff
++ && (ipaddress[1] & 0x0f) == 0x0e);
++ }
++
++ boolean isMCNodeLocal() {
++ return ((ipaddress[0] & 0xff) == 0xff
++ && (ipaddress[1] & 0x0f) == 0x01);
++ }
++
++ boolean isMCLinkLocal() {
++ return ((ipaddress[0] & 0xff) == 0xff
++ && (ipaddress[1] & 0x0f) == 0x02);
++ }
++
++ boolean isMCSiteLocal() {
++ return ((ipaddress[0] & 0xff) == 0xff
++ && (ipaddress[1] & 0x0f) == 0x05);
++ }
++
++ boolean isMCOrgLocal() {
++ return ((ipaddress[0] & 0xff) == 0xff
++ && (ipaddress[1] & 0x0f) == 0x08);
++ }
++ }
++
++ private final transient Inet6AddressHolder holder6;
+
+ private static final long serialVersionUID = 6880410070516793377L;
+
+@@ -216,37 +378,33 @@
+
+ Inet6Address() {
+ super();
+- holder().hostName = null;
+- ipaddress = new byte[INADDRSZ];
+- holder().family = IPv6;
++ holder.init(null, IPv6);
++ holder6 = new Inet6AddressHolder();
+ }
+
+ /* checking of value for scope_id should be done by caller
+ * scope_id must be >= 0, or -1 to indicate not being set
+ */
+ Inet6Address(String hostName, byte addr[], int scope_id) {
+- holder().hostName = hostName;
+- if (addr.length == INADDRSZ) { // normal IPv6 address
+- holder().family = IPv6;
+- ipaddress = addr.clone();
+- }
+- if (scope_id >= 0) {
+- this.scope_id = scope_id;
+- scope_id_set = true;
+- }
++ holder.init(hostName, IPv6);
++ holder6 = new Inet6AddressHolder();
++ holder6.init(addr, scope_id);
+ }
+
+ Inet6Address(String hostName, byte addr[]) {
++ holder6 = new Inet6AddressHolder();
+ try {
+ initif (hostName, addr, null);
+ } catch (UnknownHostException e) {} /* cant happen if ifname is null */
+ }
+
+ Inet6Address (String hostName, byte addr[], NetworkInterface nif) throws UnknownHostException {
++ holder6 = new Inet6AddressHolder();
+ initif (hostName, addr, nif);
+ }
+
+ Inet6Address (String hostName, byte addr[], String ifname) throws UnknownHostException {
++ holder6 = new Inet6AddressHolder();
+ initstr (hostName, addr, ifname);
+ }
+
+@@ -328,17 +486,13 @@
+ }
+
+ private void initif(String hostName, byte addr[],NetworkInterface nif) throws UnknownHostException {
+- holder().hostName = hostName;
++ int family = -1;
++ holder6.init(addr, nif);
++
+ if (addr.length == INADDRSZ) { // normal IPv6 address
+- holder().family = IPv6;
+- ipaddress = addr.clone();
++ family = IPv6;
+ }
+- if (nif != null) {
+- this.scope_ifname = nif;
+- scope_ifname_set = true;
+- scope_id = deriveNumericScope (nif);
+- scope_id_set = true;
+- }
++ holder.init(hostName, family);
+ }
+
+ /* check the two Ipv6 addresses and return false if they are both
+@@ -346,18 +500,21 @@
+ * (ie. one is sitelocal and the other linklocal)
+ * return true otherwise.
+ */
+- private boolean differentLocalAddressTypes(Inet6Address other) {
++ private static boolean differentLocalAddressTypes(
++ byte[] thisAddr, byte[] otherAddr) {
+
+- if (isLinkLocalAddress() && !other.isLinkLocalAddress()) {
++ if (Inet6Address.isLinkLocalAddress(thisAddr) &&
++ !Inet6Address.isLinkLocalAddress(otherAddr)) {
+ return false;
+ }
+- if (isSiteLocalAddress() && !other.isSiteLocalAddress()) {
++ if (Inet6Address.isSiteLocalAddress(thisAddr) &&
++ !Inet6Address.isSiteLocalAddress(otherAddr)) {
+ return false;
+ }
+ return true;
+ }
+
+- private int deriveNumericScope (NetworkInterface ifc) throws UnknownHostException {
++ private static int deriveNumericScope (byte[] thisAddr, NetworkInterface ifc) throws UnknownHostException {
+ Enumeration addresses = ifc.getInetAddresses();
+ while (addresses.hasMoreElements()) {
+ InetAddress address = (InetAddress)addresses.nextElement();
+@@ -366,12 +523,12 @@
+ }
+ Inet6Address ia6_addr = (Inet6Address)address;
+ /* check if site or link local prefixes match */
+- if (!differentLocalAddressTypes(ia6_addr)){
++ if (!differentLocalAddressTypes(thisAddr, ia6_addr.getAddress())){
+ /* type not the same, so carry on searching */
+ continue;
+ }
+ /* found a matching address - return its scope_id */
+- return ia6_addr.scope_id;
++ return ia6_addr.getScopeId();
+ }
+ throw new UnknownHostException ("no scope_id found");
+ }
+@@ -386,47 +543,67 @@
+ while (en.hasMoreElements()) {
+ NetworkInterface ifc = (NetworkInterface)en.nextElement();
+ if (ifc.getName().equals (ifname)) {
+- Enumeration addresses = ifc.getInetAddresses();
+- while (addresses.hasMoreElements()) {
+- InetAddress address = (InetAddress)addresses.nextElement();
+- if (!(address instanceof Inet6Address)) {
+- continue;
+- }
+- Inet6Address ia6_addr = (Inet6Address)address;
+- /* check if site or link local prefixes match */
+- if (!differentLocalAddressTypes(ia6_addr)){
+- /* type not the same, so carry on searching */
+- continue;
+- }
+- /* found a matching address - return its scope_id */
+- return ia6_addr.scope_id;
+- }
++ return deriveNumericScope(holder6.ipaddress, ifc);
+ }
+ }
+ throw new UnknownHostException ("No matching address found for interface : " +ifname);
+ }
+
+ /**
++ * @serialField ipaddress byte[]
++ * @serialField scope_id int
++ * @serialField scope_id_set boolean
++ * @serialField scope_ifname_set boolean
++ * @serialField ifname String
++ */
++
++ private static final ObjectStreamField[] serialPersistentFields = {
++ new ObjectStreamField("ipaddress", byte[].class),
++ new ObjectStreamField("scope_id", int.class),
++ new ObjectStreamField("scope_id_set", boolean.class),
++ new ObjectStreamField("scope_ifname_set", boolean.class),
++ new ObjectStreamField("ifname", String.class)
++ };
++
++ private static final long FIELDS_OFFSET;
++ private static final sun.misc.Unsafe UNSAFE;
++
++ static {
++ try {
++ sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
++ FIELDS_OFFSET = unsafe.objectFieldOffset(
++ Inet6Address.class.getDeclaredField("holder6"));
++ UNSAFE = unsafe;
++ } catch (NoSuchFieldException e) {
++ throw new Error(e);
++ }
++ }
++
++ /**
+ * restore the state of this object from stream
+ * including the scope information, only if the
+ * scoped interface name is valid on this system
+ */
+ private void readObject(ObjectInputStream s)
+ throws IOException, ClassNotFoundException {
+- scope_ifname = null;
+- scope_ifname_set = false;
++ NetworkInterface scope_ifname = null;
+
+ if (getClass().getClassLoader() != null) {
+ throw new SecurityException ("invalid address type");
+ }
+
+- s.defaultReadObject();
++ ObjectInputStream.GetField gf = s.readFields();
++ byte[] ipaddress = (byte[])gf.get("ipaddress", null);
++ int scope_id = (int)gf.get("scope_id", -1);
++ boolean scope_id_set = (boolean)gf.get("scope_id_set", false);
++ boolean scope_ifname_set = (boolean)gf.get("scope_ifname_set", false);
++ String ifname = (String)gf.get("ifname", null);
+
+ if (ifname != null && !"".equals (ifname)) {
+ try {
+ scope_ifname = NetworkInterface.getByName(ifname);
+ try {
+- scope_id = deriveNumericScope (scope_ifname);
++ scope_id = deriveNumericScope (ipaddress, scope_ifname);
+ } catch (UnknownHostException e) {
+ // should not happen
+ assert false;
+@@ -451,9 +628,37 @@
+ ipaddress.length);
+ }
+
+- if (holder().getFamily() != IPv6) {
++ if (holder.getFamily() != IPv6) {
+ throw new InvalidObjectException("invalid address family type");
+ }
++
++ Inet6AddressHolder h = new Inet6AddressHolder(
++ ipaddress, scope_id, scope_id_set, scope_ifname, scope_ifname_set
++ );
++
++ UNSAFE.putObject(this, FIELDS_OFFSET, h);
++ }
++
++ /**
++ * default behavior is overridden in order to write the
++ * scope_ifname field as a String, rather than a NetworkInterface
++ * which is not serializable
++ */
++ private synchronized void writeObject(ObjectOutputStream s)
++ throws IOException
++ {
++ String ifname = null;
++
++ if (holder6.scope_ifname_set) {
++ ifname = holder6.scope_ifname.getName();
++ }
++ ObjectOutputStream.PutField pfields = s.putFields();
++ pfields.put("ipaddress", holder6.ipaddress);
++ pfields.put("scope_id", holder6.scope_id);
++ pfields.put("scope_id_set", holder6.scope_id_set);
++ pfields.put("scope_ifname_set", holder6.scope_ifname_set);
++ pfields.put("ifname", ifname);
++ s.writeFields();
+ }
+
+ /**
+@@ -466,7 +671,7 @@
+ * @since JDK1.1
+ */
+ public boolean isMulticastAddress() {
+- return ((ipaddress[0] & 0xff) == 0xff);
++ return holder6.isMulticastAddress();
+ }
+
+ /**
+@@ -476,11 +681,7 @@
+ * @since 1.4
+ */
+ public boolean isAnyLocalAddress() {
+- byte test = 0x00;
+- for (int i = 0; i < INADDRSZ; i++) {
+- test |= ipaddress[i];
+- }
+- return (test == 0x00);
++ return holder6.isAnyLocalAddress();
+ }
+
+ /**
+@@ -491,11 +692,7 @@
+ * @since 1.4
+ */
+ public boolean isLoopbackAddress() {
+- byte test = 0x00;
+- for (int i = 0; i < 15; i++) {
+- test |= ipaddress[i];
+- }
+- return (test == 0x00) && (ipaddress[15] == 0x01);
++ return holder6.isLoopbackAddress();
+ }
+
+ /**
+@@ -506,6 +703,11 @@
+ * @since 1.4
+ */
+ public boolean isLinkLocalAddress() {
++ return holder6.isLinkLocalAddress();
++ }
++
++ /* static version of above */
++ static boolean isLinkLocalAddress(byte[] ipaddress) {
+ return ((ipaddress[0] & 0xff) == 0xfe
+ && (ipaddress[1] & 0xc0) == 0x80);
+ }
+@@ -518,6 +720,11 @@
+ * @since 1.4
+ */
+ public boolean isSiteLocalAddress() {
++ return holder6.isSiteLocalAddress();
++ }
++
++ /* static version of above */
++ static boolean isSiteLocalAddress(byte[] ipaddress) {
+ return ((ipaddress[0] & 0xff) == 0xfe
+ && (ipaddress[1] & 0xc0) == 0xc0);
+ }
+@@ -531,8 +738,7 @@
+ * @since 1.4
+ */
+ public boolean isMCGlobal() {
+- return ((ipaddress[0] & 0xff) == 0xff
+- && (ipaddress[1] & 0x0f) == 0x0e);
++ return holder6.isMCGlobal();
+ }
+
+ /**
+@@ -544,8 +750,7 @@
+ * @since 1.4
+ */
+ public boolean isMCNodeLocal() {
+- return ((ipaddress[0] & 0xff) == 0xff
+- && (ipaddress[1] & 0x0f) == 0x01);
++ return holder6.isMCNodeLocal();
+ }
+
+ /**
+@@ -557,8 +762,7 @@
+ * @since 1.4
+ */
+ public boolean isMCLinkLocal() {
+- return ((ipaddress[0] & 0xff) == 0xff
+- && (ipaddress[1] & 0x0f) == 0x02);
++ return holder6.isMCLinkLocal();
+ }
+
+ /**
+@@ -570,8 +774,7 @@
+ * @since 1.4
+ */
+ public boolean isMCSiteLocal() {
+- return ((ipaddress[0] & 0xff) == 0xff
+- && (ipaddress[1] & 0x0f) == 0x05);
++ return holder6.isMCSiteLocal();
+ }
+
+ /**
+@@ -584,10 +787,8 @@
+ * @since 1.4
+ */
+ public boolean isMCOrgLocal() {
+- return ((ipaddress[0] & 0xff) == 0xff
+- && (ipaddress[1] & 0x0f) == 0x08);
++ return holder6.isMCOrgLocal();
+ }
+-
+ /**
+ * Returns the raw IP address of this <code>InetAddress</code>
+ * object. The result is in network byte order: the highest order
+@@ -596,7 +797,7 @@
+ * @return the raw IP address of this object.
+ */
+ public byte[] getAddress() {
+- return ipaddress.clone();
++ return holder6.ipaddress.clone();
+ }
+
+ /**
+@@ -607,7 +808,7 @@
+ * @since 1.5
+ */
+ public int getScopeId () {
+- return scope_id;
++ return holder6.scope_id;
+ }
+
+ /**
+@@ -618,7 +819,7 @@
+ * @since 1.5
+ */
+ public NetworkInterface getScopedInterface () {
+- return scope_ifname;
++ return holder6.scope_ifname;
+ }
+
+ /**
+@@ -630,13 +831,7 @@
+ * @return the raw IP address in a string format.
+ */
+ public String getHostAddress() {
+- String s = numericToTextFormat(ipaddress);
+- if (scope_ifname_set) { /* must check this first */
+- s = s + "%" + scope_ifname.getName();
+- } else if (scope_id_set) {
+- s = s + "%" + scope_id;
+- }
+- return s;
++ return holder6.getHostAddress();
+ }
+
+ /**
+@@ -645,25 +840,7 @@
+ * @return a hash code value for this IP address.
+ */
+ public int hashCode() {
+- if (ipaddress != null) {
+-
+- int hash = 0;
+- int i=0;
+- while (i<INADDRSZ) {
+- int j=0;
+- int component=0;
+- while (j<4 && i<INADDRSZ) {
+- component = (component << 8) + ipaddress[i];
+- j++;
+- i++;
+- }
+- hash += component;
+- }
+- return hash;
+-
+- } else {
+- return 0;
+- }
++ return holder6.hashCode();
+ }
+
+ /**
+@@ -689,12 +866,7 @@
+
+ Inet6Address inetAddr = (Inet6Address)obj;
+
+- for (int i = 0; i < INADDRSZ; i++) {
+- if (ipaddress[i] != inetAddr.ipaddress[i])
+- return false;
+- }
+-
+- return true;
++ return holder6.equals(inetAddr.holder6);
+ }
+
+ /**
+@@ -706,15 +878,7 @@
+ * @since 1.4
+ */
+ public boolean isIPv4CompatibleAddress() {
+- if ((ipaddress[0] == 0x00) && (ipaddress[1] == 0x00) &&
+- (ipaddress[2] == 0x00) && (ipaddress[3] == 0x00) &&
+- (ipaddress[4] == 0x00) && (ipaddress[5] == 0x00) &&
+- (ipaddress[6] == 0x00) && (ipaddress[7] == 0x00) &&
+- (ipaddress[8] == 0x00) && (ipaddress[9] == 0x00) &&
+- (ipaddress[10] == 0x00) && (ipaddress[11] == 0x00)) {
+- return true;
+- }
+- return false;
++ return holder6.isIPv4CompatibleAddress();
+ }
+
+ // Utilities
+@@ -744,23 +908,4 @@
+ * Perform class load-time initializations.
+ */
+ private static native void init();
+-
+- /**
+- * Following field is only used during (de)/serialization
+- */
+- private String ifname;
+-
+- /**
+- * default behavior is overridden in order to write the
+- * scope_ifname field as a String, rather than a NetworkInterface
+- * which is not serializable
+- */
+- private synchronized void writeObject(java.io.ObjectOutputStream s)
+- throws IOException
+- {
+- if (scope_ifname_set) {
+- ifname = scope_ifname.getName();
+- }
+- s.defaultWriteObject();
+- }
+ }
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/share/classes/java/net/InetAddress.java
+--- jdk/src/share/classes/java/net/InetAddress.java Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/share/classes/java/net/InetAddress.java Tue Oct 15 21:28:50 2013 +0100
+@@ -210,6 +210,13 @@
+ this.family = family;
+ }
+
++ void init(String hostName, int family) {
++ this.hostName = hostName;
++ if (family != -1) {
++ this.family = family;
++ }
++ }
++
+ String hostName;
+
+ String getHostName() {
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/share/native/java/net/Inet6Address.c
+--- jdk/src/share/native/java/net/Inet6Address.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/share/native/java/net/Inet6Address.c Tue Oct 15 21:28:50 2013 +0100
+@@ -33,6 +33,8 @@
+ */
+
+ jclass ia6_class;
++jfieldID ia6_holder6ID;
++
+ jfieldID ia6_ipaddressID;
+ jfieldID ia6_scopeidID;
+ jfieldID ia6_cachedscopeidID;
+@@ -48,21 +50,26 @@
+ */
+ JNIEXPORT void JNICALL
+ Java_java_net_Inet6Address_init(JNIEnv *env, jclass cls) {
++ jclass ia6h_class;
+ jclass c = (*env)->FindClass(env, "java/net/Inet6Address");
+ CHECK_NULL(c);
+ ia6_class = (*env)->NewGlobalRef(env, c);
+ CHECK_NULL(ia6_class);
+- ia6_ipaddressID = (*env)->GetFieldID(env, ia6_class, "ipaddress", "[B");
++ ia6h_class = (*env)->FindClass(env, "java/net/Inet6Address$Inet6AddressHolder");
++ CHECK_NULL(ia6h_class);
++ ia6_holder6ID = (*env)->GetFieldID(env, ia6_class, "holder6", "Ljava/net/Inet6Address$Inet6AddressHolder;");
++ CHECK_NULL(ia6_holder6ID);
++ ia6_ipaddressID = (*env)->GetFieldID(env, ia6h_class, "ipaddress", "[B");
+ CHECK_NULL(ia6_ipaddressID);
+- ia6_scopeidID = (*env)->GetFieldID(env, ia6_class, "scope_id", "I");
++ ia6_scopeidID = (*env)->GetFieldID(env, ia6h_class, "scope_id", "I");
+ CHECK_NULL(ia6_scopeidID);
+ ia6_cachedscopeidID = (*env)->GetFieldID(env, ia6_class, "cached_scope_id", "I");
+ CHECK_NULL(ia6_cachedscopeidID);
+- ia6_scopeidsetID = (*env)->GetFieldID(env, ia6_class, "scope_id_set", "Z");
++ ia6_scopeidsetID = (*env)->GetFieldID(env, ia6h_class, "scope_id_set", "Z");
+ CHECK_NULL(ia6_scopeidID);
+- ia6_scopeifnameID = (*env)->GetFieldID(env, ia6_class, "scope_ifname", "Ljava/net/NetworkInterface;");
++ ia6_scopeifnameID = (*env)->GetFieldID(env, ia6h_class, "scope_ifname", "Ljava/net/NetworkInterface;");
+ CHECK_NULL(ia6_scopeifnameID);
+- ia6_scopeifnamesetID = (*env)->GetFieldID(env, ia6_class, "scope_ifname_set", "Z");
++ ia6_scopeifnamesetID = (*env)->GetFieldID(env, ia6h_class, "scope_ifname_set", "Z");
+ CHECK_NULL(ia6_scopeifnamesetID);
+ ia6_ctrID = (*env)->GetMethodID(env, ia6_class, "<init>", "()V");
+ CHECK_NULL(ia6_ctrID);
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/share/native/java/net/net_util.c
+--- jdk/src/share/native/java/net/net_util.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/share/native/java/net/net_util.c Tue Oct 15 21:28:50 2013 +0100
+@@ -94,6 +94,111 @@
+ extern jfieldID iac_addressID;
+ extern jfieldID iac_familyID;
+
++/**
++ * set_ methods return JNI_TRUE on success JNI_FALSE on error
++ * get_ methods that return +ve int return -1 on error
++ * get_ methods that return objects return NULL on error.
++ */
++jobject getInet6Address_scopeifname(JNIEnv *env, jobject iaObj) {
++ jobject holder;
++
++ init(env);
++ holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
++ CHECK_NULL_RETURN(holder, NULL);
++ return (*env)->GetObjectField(env, holder, ia6_scopeifnameID);
++}
++
++int setInet6Address_scopeifname(JNIEnv *env, jobject iaObj, jobject scopeifname) {
++ jobject holder;
++
++ init(env);
++ holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
++ CHECK_NULL_RETURN(holder, JNI_FALSE);
++ (*env)->SetObjectField(env, holder, ia6_scopeifnameID, scopeifname);
++ return JNI_TRUE;
++}
++
++int getInet6Address_scopeifname_set(JNIEnv *env, jobject iaObj) {
++ jobject holder;
++
++ init(env);
++ holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
++ CHECK_NULL_RETURN(holder, -1);
++ return (*env)->GetBooleanField(env, holder, ia6_scopeifnamesetID);
++}
++
++int setInet6Address_scopeifname_set(JNIEnv *env, jobject iaObj, int scopeifname_set) {
++ jobject holder;
++
++ init(env);
++ holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
++ CHECK_NULL_RETURN(holder, JNI_FALSE);
++ (*env)->SetBooleanField(env, holder, ia6_scopeifnamesetID, scopeifname_set);
++ return JNI_TRUE;
++}
++
++int getInet6Address_scopeid_set(JNIEnv *env, jobject iaObj) {
++ jobject holder;
++
++ init(env);
++ holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
++ CHECK_NULL_RETURN(holder, -1);
++ return (*env)->GetBooleanField(env, holder, ia6_scopeidsetID);
++}
++
++int getInet6Address_scopeid(JNIEnv *env, jobject iaObj) {
++ jobject holder;
++
++ init(env);
++ holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
++ CHECK_NULL_RETURN(holder, -1);
++ return (*env)->GetIntField(env, holder, ia6_scopeidID);
++}
++
++int setInet6Address_scopeid(JNIEnv *env, jobject iaObj, int scopeid) {
++ jobject holder;
++
++ init(env);
++ holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
++ CHECK_NULL_RETURN(holder, JNI_FALSE);
++ (*env)->SetIntField(env, holder, ia6_scopeidID, scopeid);
++ if (scopeid > 0) {
++ (*env)->SetBooleanField(env, holder, ia6_scopeidsetID, JNI_TRUE);
++ }
++ return JNI_TRUE;
++}
++
++
++int getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) {
++ jobject holder, addr;
++ jbyteArray barr;
++
++ init(env);
++ holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
++ CHECK_NULL_RETURN(holder, JNI_FALSE);
++ addr = (*env)->GetObjectField(env, holder, ia6_ipaddressID);
++ CHECK_NULL_RETURN(addr, JNI_FALSE);
++ (*env)->GetByteArrayRegion(env, addr, 0, 16, (jbyte *)dest);
++ return JNI_TRUE;
++}
++
++int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) {
++ jobject holder;
++ jbyteArray addr;
++
++ init(env);
++ holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID);
++ CHECK_NULL_RETURN(holder, JNI_FALSE);
++ addr = (jbyteArray)(*env)->GetObjectField(env, holder, ia6_ipaddressID);
++ if (addr == NULL) {
++ addr = (*env)->NewByteArray(env, 16);
++ CHECK_NULL_RETURN(addr, JNI_FALSE);
++ (*env)->SetObjectField(env, holder, ia6_ipaddressID, addr);
++ }
++ (*env)->SetByteArrayRegion(env, addr, 0, 16, (jbyte *)address);
++ return JNI_TRUE;
++}
++
+ void setInetAddress_addr(JNIEnv *env, jobject iaObj, int address) {
+ jobject holder;
+ init(env);
+@@ -166,6 +271,7 @@
+ setInetAddress_family(env, iaObj, IPv4);
+ } else {
+ static jclass inet6Cls = 0;
++ int ret;
+ if (inet6Cls == 0) {
+ jclass c = (*env)->FindClass(env, "java/net/Inet6Address");
+ CHECK_NULL_RETURN(c, NULL);
+@@ -175,15 +281,10 @@
+ }
+ iaObj = (*env)->NewObject(env, inet6Cls, ia6_ctrID);
+ CHECK_NULL_RETURN(iaObj, NULL);
+- ipaddress = (*env)->NewByteArray(env, 16);
+- CHECK_NULL_RETURN(ipaddress, NULL);
+- (*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
+- (jbyte *)&(him6->sin6_addr));
+-
+- (*env)->SetObjectField(env, iaObj, ia6_ipaddressID, ipaddress);
+-
++ ret = setInet6Address_ipaddress(env, iaObj, (char *)&(him6->sin6_addr));
++ CHECK_NULL_RETURN(ret, NULL);
+ setInetAddress_family(env, iaObj, IPv6);
+- (*env)->SetIntField(env, iaObj, ia6_scopeidID, getScopeID(him));
++ setInet6Address_scopeid(env, iaObj, getScopeID(him));
+ }
+ *port = ntohs(him6->sin6_port);
+ } else
+@@ -242,9 +343,8 @@
+ if (family == AF_INET) {
+ return JNI_FALSE;
+ }
+- ipaddress = (*env)->GetObjectField(env, iaObj, ia6_ipaddressID);
+- scope = (*env)->GetIntField(env, iaObj, ia6_scopeidID);
+- (*env)->GetByteArrayRegion(env, ipaddress, 0, 16, caddrCur);
++ scope = getInet6Address_scopeid(env, iaObj);
++ getInet6Address_ipaddress(env, iaObj, (char *)caddrCur);
+ if (NET_IsEqual(caddrNew, caddrCur) && cmpScopeID(scope, him)) {
+ return JNI_TRUE;
+ } else {
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/share/native/java/net/net_util.h
+--- jdk/src/share/native/java/net/net_util.h Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/share/native/java/net/net_util.h Tue Oct 15 21:28:50 2013 +0100
+@@ -58,6 +58,22 @@
+ extern jfieldID iac_hostNameID;
+ extern jfieldID ia_preferIPv6AddressID;
+
++/** (Inet6Address accessors)
++ * set_ methods return JNI_TRUE on success JNI_FALSE on error
++ * get_ methods that return int/boolean, return -1 on error
++ * get_ methods that return objects return NULL on error.
++ */
++extern jobject getInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj);
++extern int setInet6Address_scopeifname(JNIEnv *env, jobject ia6Obj, jobject scopeifname);
++extern int getInet6Address_scopeifname_set(JNIEnv *env, jobject ia6Obj);
++extern int setInet6Address_scopeifname_set(JNIEnv *env, jobject ia6Obj,
++ int scopeifname_set);
++extern int getInet6Address_scopeid_set(JNIEnv *env, jobject ia6Obj);
++extern int getInet6Address_scopeid(JNIEnv *env, jobject ia6Obj);
++extern int setInet6Address_scopeid(JNIEnv *env, jobject ia6Obj, int scopeid);
++extern int getInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *dest);
++extern int setInet6Address_ipaddress(JNIEnv *env, jobject ia6Obj, char *address);
++
+ extern void setInetAddress_addr(JNIEnv *env, jobject iaObj, int address);
+ extern void setInetAddress_family(JNIEnv *env, jobject iaObj, int family);
+ extern void setInetAddress_hostName(JNIEnv *env, jobject iaObj, jobject h);
+@@ -93,6 +109,7 @@
+
+ /* Inet6Address fields */
+ extern jclass ia6_class;
++extern jfieldID ia6_holder6ID;
+ extern jfieldID ia6_ipaddressID;
+ extern jfieldID ia6_scopeidID;
+ extern jfieldID ia6_cachedscopeidID;
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/solaris/native/java/net/Inet6AddressImpl.c
+--- jdk/src/solaris/native/java/net/Inet6AddressImpl.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/solaris/native/java/net/Inet6AddressImpl.c Tue Oct 15 21:28:50 2013 +0100
+@@ -120,7 +120,6 @@
+ static jclass ni_ia6cls;
+ static jmethodID ni_ia4ctrID;
+ static jmethodID ni_ia6ctrID;
+-static jfieldID ni_ia6ipaddressID;
+ static int initialized = 0;
+
+ /*
+@@ -158,7 +157,6 @@
+ ni_ia6cls = (*env)->NewGlobalRef(env, ni_ia6cls);
+ ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V");
+ ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "<init>", "()V");
+- ni_ia6ipaddressID = (*env)->GetFieldID(env, ni_ia6cls, "ipaddress", "[B");
+ initialized = 1;
+ }
+
+@@ -310,6 +308,7 @@
+ goto cleanupAndReturn;
+ }
+ while (iterator != NULL) {
++ int ret1;
+ if (iterator->ai_family == AF_INET) {
+ jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
+ if (IS_NULL(iaObj)) {
+@@ -322,20 +321,17 @@
+ inetIndex++;
+ } else if (iterator->ai_family == AF_INET6) {
+ jint scope = 0;
+- jbyteArray ipaddress;
+
+ jobject iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID);
+ if (IS_NULL(iaObj)) {
+ ret = NULL;
+ goto cleanupAndReturn;
+ }
+- ipaddress = (*env)->NewByteArray(env, 16);
+- if (IS_NULL(ipaddress)) {
+- ret = NULL;
+- goto cleanupAndReturn;
++ ret1 = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
++ if (!ret1) {
++ ret = NULL;
++ goto cleanupAndReturn;
+ }
+- (*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
+- (jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
+ #ifdef __linux__
+ if (!kernelIsV22()) {
+ scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
+@@ -344,10 +340,8 @@
+ scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
+ #endif
+ if (scope != 0) { /* zero is default value, no need to set */
+- (*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
+- (*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
++ setInet6Address_scopeid(env, iaObj, scope);
+ }
+- (*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
+ setInetAddress_hostName(env, iaObj, name);
+ (*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
+ inet6Index++;
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/solaris/native/java/net/NetworkInterface.c
+--- jdk/src/solaris/native/java/net/NetworkInterface.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/solaris/native/java/net/NetworkInterface.c Tue Oct 15 21:28:50 2013 +0100
+@@ -101,7 +101,6 @@
+ static jmethodID ni_ia4ctrID;
+ static jmethodID ni_ia6ctrID;
+ static jmethodID ni_ibctrID;
+-static jfieldID ni_ia6ipaddressID;
+ static jfieldID ni_ibaddressID;
+ static jfieldID ni_ib4broadcastID;
+ static jfieldID ni_ib4maskID;
+@@ -151,7 +150,6 @@
+ ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V");
+ ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "<init>", "()V");
+ ni_ibctrID = (*env)->GetMethodID(env, ni_ibcls, "<init>", "()V");
+- ni_ia6ipaddressID = (*env)->GetFieldID(env, ni_ia6cls, "ipaddress", "[B");
+ ni_ibaddressID = (*env)->GetFieldID(env, ni_ibcls, "address", "Ljava/net/InetAddress;");
+ ni_ib4broadcastID = (*env)->GetFieldID(env, ni_ibcls, "broadcast", "Ljava/net/Inet4Address;");
+ ni_ib4maskID = (*env)->GetFieldID(env, ni_ibcls, "maskLength", "S");
+@@ -281,11 +279,9 @@
+ #ifdef AF_INET6
+ if (family == AF_INET6) {
+ jbyte *bytes = (jbyte *)&(((struct sockaddr_in6*)addrP->addr)->sin6_addr);
+- jbyteArray ipaddress = (*env)->GetObjectField(env, iaObj, ni_ia6ipaddressID);
+ jbyte caddr[16];
+ int i;
+-
+- (*env)->GetByteArrayRegion(env, ipaddress, 0, 16, caddr);
++ getInet6Address_ipaddress(env, iaObj, (char *)caddr);
+ i = 0;
+ while (i < 16) {
+ if (caddr[i] != bytes[i]) {
+@@ -468,12 +464,10 @@
+ int scope=0;
+ iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID);
+ if (iaObj) {
+- jbyteArray ipaddress = (*env)->NewByteArray(env, 16);
+- if (ipaddress == NULL) {
++ int ret = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)addrP->addr)->sin6_addr));
++ if (ret == JNI_FALSE) {
+ return NULL;
+ }
+- (*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
+- (jbyte *)&(((struct sockaddr_in6*)addrP->addr)->sin6_addr));
+ #ifdef __linux__
+ if (!kernelIsV22()) {
+ scope = ((struct sockaddr_in6*)addrP->addr)->sin6_scope_id;
+@@ -482,11 +476,9 @@
+ scope = ((struct sockaddr_in6*)addrP->addr)->sin6_scope_id;
+ #endif
+ if (scope != 0) { /* zero is default value, no need to set */
+- (*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
+- (*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
+- (*env)->SetObjectField(env, iaObj, ia6_scopeifnameID, netifObj);
++ setInet6Address_scopeid(env, iaObj, scope);
++ setInet6Address_scopeifname(env, iaObj, netifObj);
+ }
+- (*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
+ }
+ ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
+ if (ibObj) {
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/solaris/native/java/net/PlainDatagramSocketImpl.c
+--- jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c Tue Oct 15 21:28:50 2013 +0100
+@@ -2311,8 +2311,7 @@
+ caddr[14] = ((address >> 8) & 0xff);
+ caddr[15] = (address & 0xff);
+ } else {
+- ipaddress = (*env)->GetObjectField(env, iaObj, ia6_ipaddressID);
+- (*env)->GetByteArrayRegion(env, ipaddress, 0, 16, caddr);
++ getInet6Address_ipaddress(env, iaObj, caddr);
+ }
+
+ memcpy((void *)&(mname6.ipv6mr_multiaddr), caddr, sizeof(struct in6_addr));
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/solaris/native/java/net/net_util_md.c
+--- jdk/src/solaris/native/java/net/net_util_md.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/solaris/native/java/net/net_util_md.c Tue Oct 15 21:28:50 2013 +0100
+@@ -680,7 +680,6 @@
+ /* needs work. 1. family 2. clean up him6 etc deallocate memory */
+ if (ipv6_available() && !(family == IPv4 && v4MappedAddress == JNI_FALSE)) {
+ struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
+- jbyteArray ipaddress;
+ jbyte caddr[16];
+ jint address;
+
+@@ -701,8 +700,7 @@
+ caddr[15] = (address & 0xff);
+ }
+ } else {
+- ipaddress = (*env)->GetObjectField(env, iaObj, ia6_ipaddressID);
+- (*env)->GetByteArrayRegion(env, ipaddress, 0, 16, caddr);
++ getInet6Address_ipaddress(env, iaObj, (char *)caddr);
+ }
+ memset((char *)him6, 0, sizeof(struct sockaddr_in6));
+ him6->sin6_port = htons(port);
+@@ -734,7 +732,7 @@
+ */
+ if (!cached_scope_id) {
+ if (ia6_scopeidID) {
+- scope_id = (int)(*env)->GetIntField(env,iaObj,ia6_scopeidID);
++ scope_id = getInet6Address_scopeid(env, iaObj);
+ }
+ if (scope_id != 0) {
+ /* check user-specified value for loopback case
+@@ -780,7 +778,7 @@
+
+ if (family != IPv4) {
+ if (ia6_scopeidID) {
+- him6->sin6_scope_id = (int)(*env)->GetIntField(env, iaObj, ia6_scopeidID);
++ him6->sin6_scope_id = getInet6Address_scopeid(env, iaObj);
+ }
+ }
+ #endif
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/windows/native/java/net/Inet6AddressImpl.c
+--- jdk/src/windows/native/java/net/Inet6AddressImpl.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/windows/native/java/net/Inet6AddressImpl.c Tue Oct 15 21:28:50 2013 +0100
+@@ -76,7 +76,6 @@
+ static jclass ni_ia6cls;
+ static jmethodID ni_ia4ctrID;
+ static jmethodID ni_ia6ctrID;
+-static jfieldID ni_ia6ipaddressID;
+ static int initialized = 0;
+
+ JNIEXPORT jobjectArray JNICALL
+@@ -100,7 +99,6 @@
+ ni_ia6cls = (*env)->NewGlobalRef(env, ni_ia6cls);
+ ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "<init>", "()V");
+ ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "<init>", "()V");
+- ni_ia6ipaddressID = (*env)->GetFieldID(env, ni_ia6cls, "ipaddress", "[B");
+ initialized = 1;
+ }
+ if (IS_NULL(host)) {
+@@ -249,26 +247,22 @@
+ (*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
+ inetIndex ++;
+ } else if (iterator->ai_family == AF_INET6) {
+- jint scope = 0;
+- jbyteArray ipaddress;
++ jint scope = 0, ret1;
+ jobject iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID);
+ if (IS_NULL(iaObj)) {
+ ret = NULL;
+ goto cleanupAndReturn;
+ }
+- ipaddress = (*env)->NewByteArray(env, 16);
+- if (IS_NULL(ipaddress)) {
++ ret1 = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
++
++ if (ret1 == JNI_FALSE) {
+ ret = NULL;
+ goto cleanupAndReturn;
+ }
+- (*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
+- (jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
+ scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
+ if (scope != 0) { /* zero is default value, no need to set */
+- (*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
+- (*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
++ setInet6Address_scopeid(env, iaObj, scope);
+ }
+- (*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
+ setInetAddress_hostName(env, iaObj, name);
+ (*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
+ inet6Index ++;
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/windows/native/java/net/NetworkInterface.c
+--- jdk/src/windows/native/java/net/NetworkInterface.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/windows/native/java/net/NetworkInterface.c Tue Oct 15 21:28:50 2013 +0100
+@@ -103,8 +103,6 @@
+
+ jclass ni_ia6cls; /* Inet6Address */
+ jmethodID ni_ia6ctrID; /* Inet6Address() */
+-jfieldID ni_ia6ipaddressID;
+-jfieldID ni_ia6ipaddressID;
+
+ jclass ni_ibcls; /* InterfaceAddress */
+ jmethodID ni_ibctrID; /* InterfaceAddress() */
+@@ -565,7 +563,6 @@
+ ni_ia6cls = (*env)->FindClass(env, "java/net/Inet6Address");
+ ni_ia6cls = (*env)->NewGlobalRef(env, ni_ia6cls);
+ ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "<init>", "()V");
+- ni_ia6ipaddressID = (*env)->GetFieldID(env, ni_ia6cls, "ipaddress", "[B");
+
+ ni_ibcls = (*env)->FindClass(env, "java/net/InterfaceAddress");
+ ni_ibcls = (*env)->NewGlobalRef(env, ni_ibcls);
+@@ -665,19 +662,16 @@
+ int scope;
+ iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID);
+ if (iaObj) {
+- jbyteArray ipaddress = (*env)->NewByteArray(env, 16);
+- if (ipaddress == NULL) {
++ int ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
++ if (ret == JNI_FALSE) {
+ return NULL;
+ }
+- (*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
+- (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
++
+ scope = addrs->addr.him6.sin6_scope_id;
+ if (scope != 0) { /* zero is default value, no need to set */
+- (*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
+- (*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
+- (*env)->SetObjectField(env, iaObj, ia6_scopeifnameID, netifObj);
++ setInet6Address_scopeid(env, iaObj, scope);
++ setInet6Address_scopeifname(env, iaObj, netifObj);
+ }
+- (*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
+ ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
+ if (ibObj == NULL) {
+ free_netaddr(netaddrP);
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/windows/native/java/net/NetworkInterface_winXP.c
+--- jdk/src/windows/native/java/net/NetworkInterface_winXP.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/windows/native/java/net/NetworkInterface_winXP.c Tue Oct 15 21:28:50 2013 +0100
+@@ -490,19 +490,15 @@
+ int scope;
+ iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID);
+ if (iaObj) {
+- jbyteArray ipaddress = (*env)->NewByteArray(env, 16);
+- if (ipaddress == NULL) {
++ int ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
++ if (ret == JNI_FALSE) {
+ return NULL;
+ }
+- (*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
+- (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr));
+ scope = addrs->addr.him6.sin6_scope_id;
+ if (scope != 0) { /* zero is default value, no need to set */
+- (*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
+- (*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
+- (*env)->SetObjectField(env, iaObj, ia6_scopeifnameID, netifObj);
++ setInet6Address_scopeid(env, iaObj, scope);
++ setInet6Address_scopeifname(env, iaObj, netifObj);
+ }
+- (*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
+ ibObj = (*env)->NewObject(env, ni_ibcls, ni_ibctrID);
+ if (ibObj == NULL) {
+ free_netaddr(netaddrP);
+diff -r e10e9bfb11b0 -r 96aee3742c52 src/windows/native/java/net/TwoStacksPlainSocketImpl.c
+--- jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c Thu Jun 13 10:31:21 2013 +0800
++++ jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c Tue Oct 15 21:28:50 2013 +0100
+@@ -726,7 +726,6 @@
+ setInetAddress_family(env, socketAddressObj, IPv4);
+ (*env)->SetObjectField(env, socket, psi_addressID, socketAddressObj);
+ } else {
+- jbyteArray addr;
+ /* AF_INET6 -> Inet6Address */
+ if (inet6Cls == 0) {
+ jclass c = (*env)->FindClass(env, "java/net/Inet6Address");
+@@ -749,10 +748,10 @@
+ NET_SocketClose(fd);
+ return;
+ }
+- addr = (*env)->GetObjectField (env, socketAddressObj, ia6_ipaddressID);
+- (*env)->SetByteArrayRegion (env, addr, 0, 16, (const char *)&him.him6.sin6_addr);
++ setInet6Address_ipaddress(env, socketAddressObj, (const char *)&him.him6.sin6_addr);
++
+ setInetAddress_family(env, socketAddressObj, IPv6);
+- (*env)->SetIntField(env, socketAddressObj, ia6_scopeidID, him.him6.sin6_scope_id);
++ setInet6Address_scopeid(env, socketAddressObj, him.him6.sin6_scope_id);
+ }
+ /* fields common to AF_INET and AF_INET6 */
+
diff --git a/java/openjdk6/files/icedtea/openjdk/8015965-typo_in_property_name.patch b/java/openjdk6/files/icedtea/openjdk/8015965-typo_in_property_name.patch
new file mode 100644
index 000000000000..0a064060c57e
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8015965-typo_in_property_name.patch
@@ -0,0 +1,42 @@
+# HG changeset patch
+# User coffeys
+# Date 1370453984 -3600
+# Wed Jun 05 18:39:44 2013 +0100
+# Node ID 35c5b3f404aac29ec5cccaeb32106af47546b6db
+# Parent 20c88fd14959c6a4df2e0f36bd759b56efa6f2cb
+8015965: (process) Typo in name of property to allow ambiguous commands
+Reviewed-by: alanb
+
+diff -r 20c88fd14959 -r 35c5b3f404aa src/windows/classes/java/lang/ProcessImpl.java
+--- jdk/src/windows/classes/java/lang/ProcessImpl.java Tue Oct 29 01:07:01 2013 +0000
++++ jdk/src/windows/classes/java/lang/ProcessImpl.java Wed Jun 05 18:39:44 2013 +0100
+@@ -218,13 +218,13 @@
+ {
+ String cmdstr;
+ SecurityManager security = System.getSecurityManager();
+- boolean allowAmbigousCommands = false;
++ boolean allowAmbiguousCommands = false;
+ if (security == null) {
+- String value = System.getProperty("jdk.lang.Process.allowAmbigousCommands");
++ String value = System.getProperty("jdk.lang.Process.allowAmbiguousCommands");
+ if (value != null)
+- allowAmbigousCommands = !"false".equalsIgnoreCase(value);
++ allowAmbiguousCommands = !"false".equalsIgnoreCase(value);
+ }
+- if (allowAmbigousCommands) {
++ if (allowAmbiguousCommands) {
+ // Legacy mode.
+
+ // Normalize path if possible.
+diff -r 20c88fd14959 -r 35c5b3f404aa test/java/lang/Runtime/exec/ExecCommand.java
+--- jdk/test/java/lang/Runtime/exec/ExecCommand.java Tue Oct 29 01:07:01 2013 +0000
++++ jdk/test/java/lang/Runtime/exec/ExecCommand.java Wed Jun 05 18:39:44 2013 +0100
+@@ -129,7 +129,7 @@
+ for (int k = 0; k < 3; ++k) {
+ switch (k) {
+ case 1:
+- System.setProperty("jdk.lang.Process.allowAmbigousCommands", "");
++ System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "");
+ break;
+ case 2:
+ System.setSecurityManager( new SecurityMan() );
diff --git a/java/openjdk6/files/icedtea/openjdk/8015978-incorrect_transformation.patch b/java/openjdk6/files/icedtea/openjdk/8015978-incorrect_transformation.patch
new file mode 100644
index 000000000000..1bfbb3b8f64e
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8015978-incorrect_transformation.patch
@@ -0,0 +1,22 @@
+# HG changeset patch
+# User aefimov
+# Date 1383034304 0
+# Tue Oct 29 08:11:44 2013 +0000
+# Node ID efb24af909a020f3a3b3d446f6db15fc8b1c309a
+# Parent 20ffb814205c67b5ded678ee6c69b2aa0d6cebb1
+8015978: Incorrect transformation of XPath expression "string(-0)"
+Reviewed-by: darcy, joehw
+
+diff -r 20ffb814205c -r efb24af909a0 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Tue Oct 29 08:10:15 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Tue Oct 29 08:11:44 2013 +0000
+@@ -950,6 +950,9 @@
+ if (Double.isNaN(d) || Double.isInfinite(d))
+ return(Double.toString(d));
+
++ //Convert -0.0 to +0.0 other values remains the same
++ d = d + 0.0;
++
+ // Use the XPath formatter to ignore locales
+ StringBuffer result = threadLocalStringBuffer.get();
+ result.setLength(0);
diff --git a/java/openjdk6/files/icedtea/openjdk/8016256-finalization_final.patch b/java/openjdk6/files/icedtea/openjdk/8016256-finalization_final.patch
new file mode 100644
index 000000000000..97e49ca9adfc
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8016256-finalization_final.patch
@@ -0,0 +1,24 @@
+# HG changeset patch
+# User sgabdura
+# Date 1373869363 -14400
+# Mon Jul 15 10:22:43 2013 +0400
+# Node ID bbd051c9089f61c65fe7d95487d47920164c7ee0
+# Parent 918a90950fa69e5247e3af2599d2e7674d64e3d6
+8016256: Make finalization final
+Reviewed-by: hseigel
+
+diff -r 918a90950fa6 -r bbd051c9089f src/share/vm/classfile/classFileParser.cpp
+--- hotspot/src/share/vm/classfile/classFileParser.cpp Thu Oct 10 16:41:17 2013 +0100
++++ hotspot/src/share/vm/classfile/classFileParser.cpp Mon Jul 15 10:22:43 2013 +0400
+@@ -3762,9 +3762,8 @@
+ for (int index = 0; index < num_methods; index++) {
+ methodOop m = (methodOop)methods->obj_at(index);
+
+- // skip private, static and <init> methods
+- if ((!m->is_private()) &&
+- (!m->is_static()) &&
++ // skip static and <init> methods
++ if ((!m->is_static()) &&
+ (m->name() != vmSymbols::object_initializer_name())) {
+
+ Symbol* name = m->name();
diff --git a/java/openjdk6/files/icedtea/openjdk/8016357-update_hs_diagnostic_class.patch b/java/openjdk6/files/icedtea/openjdk/8016357-update_hs_diagnostic_class.patch
new file mode 100644
index 000000000000..7c7546939574
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8016357-update_hs_diagnostic_class.patch
@@ -0,0 +1,71 @@
+# HG changeset patch
+# User sgabdura
+# Date 1381896654 -3600
+# Wed Oct 16 05:10:54 2013 +0100
+# Node ID 1ed7c9cea8c508e60d6df30c046ab48b1f1d3ab9
+# Parent 96aee3742c52d2d1a83a3db0be2c14892a511c67
+8016357: Update hotspot diagnostic class
+Summary: Add security check to HotSpotDiagnostic.dumpHeap
+Reviewed-by: fparain, sla, ahgross
+
+diff -r 96aee3742c52 -r 1ed7c9cea8c5 make/java/management/mapfile-vers
+--- jdk/make/java/management/mapfile-vers Tue Oct 15 21:28:50 2013 +0100
++++ jdk/make/java/management/mapfile-vers Wed Oct 16 05:10:54 2013 +0100
+@@ -50,7 +50,7 @@
+ Java_sun_management_GcInfoBuilder_fillGcAttributeInfo;
+ Java_sun_management_GcInfoBuilder_getLastGcInfo0;
+ Java_sun_management_GcInfoBuilder_getNumGcExtAttributes;
+- Java_sun_management_HotSpotDiagnostic_dumpHeap;
++ Java_sun_management_HotSpotDiagnostic_dumpHeap0;
+ Java_sun_management_HotspotThread_getInternalThreadCount;
+ Java_sun_management_HotspotThread_getInternalThreadTimes0;
+ Java_sun_management_MemoryImpl_getMemoryManagers0;
+diff -r 96aee3742c52 -r 1ed7c9cea8c5 src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java
+--- jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Tue Oct 15 21:28:50 2013 +0100
++++ jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Wed Oct 16 05:10:54 2013 +0100
+@@ -54,6 +54,11 @@
+ * cannot be created, opened, or written to.
+ * @throws UnsupportedOperationException if this operation is not supported.
+ * @throws NullPointerException if <tt>outputFile</tt> is <tt>null</tt>.
++ * @throws SecurityException
++ * If a security manager exists and its {@link
++ * java.lang.SecurityManager#checkWrite(java.lang.String)}
++ * method denies write access to the named file
++ * or the caller does not have ManagmentPermission("control").
+ */
+ public void dumpHeap(String outputFile, boolean live) throws java.io.IOException;
+
+diff -r 96aee3742c52 -r 1ed7c9cea8c5 src/share/classes/sun/management/HotSpotDiagnostic.java
+--- jdk/src/share/classes/sun/management/HotSpotDiagnostic.java Tue Oct 15 21:28:50 2013 +0100
++++ jdk/src/share/classes/sun/management/HotSpotDiagnostic.java Wed Oct 16 05:10:54 2013 +0100
+@@ -38,7 +38,17 @@
+ public HotSpotDiagnostic() {
+ }
+
+- public native void dumpHeap(String outputFile, boolean live) throws IOException;
++ public void dumpHeap(String outputFile, boolean live) throws IOException {
++ SecurityManager security = System.getSecurityManager();
++ if (security != null) {
++ security.checkWrite(outputFile);
++ ManagementFactory.checkControlAccess();
++ }
++
++ dumpHeap0(outputFile, live);
++ }
++
++ private native void dumpHeap0(String outputFile, boolean live) throws IOException;
+
+ public List<VMOption> getDiagnosticOptions() {
+ List<Flag> allFlags = Flag.getAllFlags();
+diff -r 96aee3742c52 -r 1ed7c9cea8c5 src/share/native/sun/management/HotSpotDiagnostic.c
+--- jdk/src/share/native/sun/management/HotSpotDiagnostic.c Tue Oct 15 21:28:50 2013 +0100
++++ jdk/src/share/native/sun/management/HotSpotDiagnostic.c Wed Oct 16 05:10:54 2013 +0100
+@@ -29,7 +29,7 @@
+ #include "sun_management_HotSpotDiagnostic.h"
+
+ JNIEXPORT void JNICALL
+-Java_sun_management_HotSpotDiagnostic_dumpHeap
++Java_sun_management_HotSpotDiagnostic_dumpHeap0
+ (JNIEnv *env, jobject dummy, jstring outputfile, jboolean live)
+ {
+ jmm_interface->DumpHeap0(env, outputfile, live);
diff --git a/java/openjdk6/files/icedtea/openjdk/8016653-ignoreable_characters.patch b/java/openjdk6/files/icedtea/openjdk/8016653-ignoreable_characters.patch
new file mode 100644
index 000000000000..23f2d235facc
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8016653-ignoreable_characters.patch
@@ -0,0 +1,101 @@
+# HG changeset patch
+# User robm
+# Date 1383034867 0
+# Tue Oct 29 08:21:07 2013 +0000
+# Node ID e6d4480e2b11853e5ec5bbced3d351564e174632
+# Parent 843659ece699889459239c6470e67265de2b3f73
+8016653: javadoc should ignore ignoreable characters in names
+Reviewed-by: jjg
+
+diff -r 843659ece699 -r e6d4480e2b11 src/share/classes/com/sun/tools/javac/parser/Scanner.java
+--- langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Fri Jul 19 16:02:59 2013 -0700
++++ langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Tue Oct 29 08:21:07 2013 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2006, 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
+@@ -514,11 +514,10 @@
+ private void scanIdent() {
+ boolean isJavaIdentifierPart;
+ char high;
++ if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
++ // optimization, was: putChar(ch);
++ scanChar();
+ do {
+- if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
+- // optimization, was: putChar(ch);
+-
+- scanChar();
+ switch (ch) {
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+@@ -535,6 +534,7 @@
+ case '$': case '_':
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
++ break;
+ case '\u0000': case '\u0001': case '\u0002': case '\u0003':
+ case '\u0004': case '\u0005': case '\u0006': case '\u0007':
+ case '\u0008': case '\u000E': case '\u000F': case '\u0010':
+@@ -542,30 +542,37 @@
+ case '\u0015': case '\u0016': case '\u0017':
+ case '\u0018': case '\u0019': case '\u001B':
+ case '\u007F':
+- break;
++ scanChar();
++ continue;
+ case '\u001A': // EOI is also a legal identifier part
+ if (bp >= buflen) {
+ name = names.fromChars(sbuf, 0, sp);
+ token = keywords.key(name);
+ return;
+ }
+- break;
++ scanChar();
++ continue;
+ default:
+ if (ch < '\u0080') {
+ // all ASCII range chars already handled, above
+ isJavaIdentifierPart = false;
+ } else {
+- high = scanSurrogates();
+- if (high != 0) {
+- if (sp == sbuf.length) {
+- putChar(high);
++ if (Character.isIdentifierIgnorable(ch)) {
++ scanChar();
++ continue;
++ } else {
++ high = scanSurrogates();
++ if (high != 0) {
++ if (sp == sbuf.length) {
++ putChar(high);
++ } else {
++ sbuf[sp++] = high;
++ }
++ isJavaIdentifierPart = Character.isJavaIdentifierPart(
++ Character.toCodePoint(high, ch));
+ } else {
+- sbuf[sp++] = high;
++ isJavaIdentifierPart = Character.isJavaIdentifierPart(ch);
+ }
+- isJavaIdentifierPart = Character.isJavaIdentifierPart(
+- Character.toCodePoint(high, ch));
+- } else {
+- isJavaIdentifierPart = Character.isJavaIdentifierPart(ch);
+ }
+ }
+ if (!isJavaIdentifierPart) {
+@@ -574,6 +581,9 @@
+ return;
+ }
+ }
++ if (sp == sbuf.length) putChar(ch); else sbuf[sp++] = ch;
++ // optimization, was: putChar(ch);
++ scanChar();
+ } while (true);
+ }
+
diff --git a/java/openjdk6/files/icedtea/openjdk/8016675-robust_javadoc.patch b/java/openjdk6/files/icedtea/openjdk/8016675-robust_javadoc.patch
new file mode 100644
index 000000000000..191516077a43
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8016675-robust_javadoc.patch
@@ -0,0 +1,75 @@
+# HG changeset patch
+# User bpatel
+# Date 1374274979 25200
+# Fri Jul 19 16:02:59 2013 -0700
+# Node ID 843659ece699889459239c6470e67265de2b3f73
+# Parent 9083313d5733ca9be66bc52cf64b9b5d4dd2e39a
+8016675: Make Javadoc pages more robust
+Reviewed-by: jlaskey, ksrini
+
+diff -r 9083313d5733 -r 843659ece699 src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+--- langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Fri Oct 25 16:10:09 2013 +0100
++++ langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java Fri Jul 19 16:02:59 2013 -0700
+@@ -289,7 +289,7 @@
+ script.addAttr(HtmlAttr.TYPE, "text/javascript");
+ String scriptCode = "<!--" + DocletConstants.NL +
+ " if (location.href.indexOf('is-external=true') == -1) {" + DocletConstants.NL +
+- " parent.document.title=\"" + winTitle + "\";" + DocletConstants.NL +
++ " parent.document.title=\"" + escapeJavaScriptChars(winTitle) + "\";" + DocletConstants.NL +
+ " }" + DocletConstants.NL +
+ "//-->" + DocletConstants.NL;
+ RawHtml scriptContent = new RawHtml(scriptCode);
+@@ -299,6 +299,53 @@
+ }
+
+ /**
++ * Returns a String with escaped special JavaScript characters.
++ *
++ * @param s String that needs to be escaped
++ * @return a valid escaped JavaScript string
++ */
++ private static String escapeJavaScriptChars(String s) {
++ StringBuilder sb = new StringBuilder();
++ for (int i = 0; i < s.length(); i++) {
++ char ch = s.charAt(i);
++ switch (ch) {
++ case '\b':
++ sb.append("\\b");
++ break;
++ case '\t':
++ sb.append("\\t");
++ break;
++ case '\n':
++ sb.append("\\n");
++ break;
++ case '\f':
++ sb.append("\\f");
++ break;
++ case '\r':
++ sb.append("\\r");
++ break;
++ case '"':
++ sb.append("\\\"");
++ break;
++ case '\'':
++ sb.append("\\\'");
++ break;
++ case '\\':
++ sb.append("\\\\");
++ break;
++ default:
++ if (ch < 32 || ch >= 127) {
++ sb.append(String.format("\\u%04X", (int)ch));
++ } else {
++ sb.append(ch);
++ }
++ break;
++ }
++ }
++ return sb.toString();
++ }
++
++ /**
+ * Returns a content tree for the SCRIPT tag for the main page(index.html).
+ *
+ * @return a content for the SCRIPT tag
diff --git a/java/openjdk6/files/icedtea/openjdk/8017196-ensure_proxies_are_handled_appropriately-jdk.patch b/java/openjdk6/files/icedtea/openjdk/8017196-ensure_proxies_are_handled_appropriately-jdk.patch
new file mode 100644
index 000000000000..0fab3210af7d
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8017196-ensure_proxies_are_handled_appropriately-jdk.patch
@@ -0,0 +1,107 @@
+# HG changeset patch
+# User mchung
+# Date 1382731288 -3600
+# Fri Oct 25 21:01:28 2013 +0100
+# Node ID 43b600fed0e8ac9d5ffe7556617d4850143e2dcd
+# Parent a2b63addc0633a5ef8d196d1019d78b920cb4b1a
+8017196: Ensure Proxies are handled appropriately
+Reviewed-by: dfuchs, jrose, jdn, ahgross, chegar
+
+diff -r a2b63addc063 -r 43b600fed0e8 src/share/classes/java/lang/reflect/Proxy.java
+--- jdk/src/share/classes/java/lang/reflect/Proxy.java Fri Oct 25 19:45:04 2013 +0100
++++ jdk/src/share/classes/java/lang/reflect/Proxy.java Fri Oct 25 21:01:28 2013 +0100
+@@ -787,6 +787,7 @@
+ * @throws IllegalArgumentException if the argument is not a
+ * proxy instance
+ */
++ @CallerSensitive
+ public static InvocationHandler getInvocationHandler(Object proxy)
+ throws IllegalArgumentException
+ {
+@@ -797,8 +798,19 @@
+ throw new IllegalArgumentException("not a proxy instance");
+ }
+
+- Proxy p = (Proxy) proxy;
+- return p.h;
++ final Proxy p = (Proxy) proxy;
++ final InvocationHandler ih = p.h;
++ if (System.getSecurityManager() != null) {
++ Class<?> ihClass = ih.getClass();
++ Class<?> caller = Reflection.getCallerClass();
++ if (ReflectUtil.needsPackageAccessCheck(caller.getClassLoader(),
++ ihClass.getClassLoader()))
++ {
++ ReflectUtil.checkPackageAccess(ihClass);
++ }
++ }
++
++ return ih;
+ }
+
+ private static native Class defineClass0(ClassLoader loader, String name,
+diff -r a2b63addc063 -r 43b600fed0e8 src/share/classes/sun/reflect/misc/ReflectUtil.java
+--- jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Fri Oct 25 19:45:04 2013 +0100
++++ jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Fri Oct 25 21:01:28 2013 +0100
+@@ -26,8 +26,10 @@
+
+ package sun.reflect.misc;
+
++import java.lang.reflect.Method;
+ import java.lang.reflect.Modifier;
+ import java.lang.reflect.Proxy;
++import java.util.Arrays;
+ import sun.reflect.Reflection;
+
+ public final class ReflectUtil {
+@@ -257,4 +259,50 @@
+ String pkg = (i != -1) ? name.substring(0, i) : "";
+ return Proxy.isProxyClass(cls) && !pkg.equals(PROXY_PACKAGE);
+ }
++
++ /**
++ * Check if the given method is a method declared in the proxy interface
++ * implemented by the given proxy instance.
++ *
++ * @param proxy a proxy instance
++ * @param method an interface method dispatched to a InvocationHandler
++ *
++ * @throws IllegalArgumentException if the given proxy or method is invalid.
++ */
++ public static void checkProxyMethod(Object proxy, Method method) {
++ // check if it is a valid proxy instance
++ if (proxy == null || !Proxy.isProxyClass(proxy.getClass())) {
++ throw new IllegalArgumentException("Not a Proxy instance");
+ }
++ if (Modifier.isStatic(method.getModifiers())) {
++ throw new IllegalArgumentException("Can't handle static method");
++ }
++
++ Class<?> c = method.getDeclaringClass();
++ if (c == Object.class) {
++ String name = method.getName();
++ if (name.equals("hashCode") || name.equals("equals") || name.equals("toString")) {
++ return;
++ }
++ }
++
++ if (isSuperInterface(proxy.getClass(), c)) {
++ return;
++ }
++
++ // disallow any method not declared in one of the proxy intefaces
++ throw new IllegalArgumentException("Can't handle: " + method);
++ }
++
++ private static boolean isSuperInterface(Class<?> c, Class<?> intf) {
++ for (Class<?> i : c.getInterfaces()) {
++ if (i == intf) {
++ return true;
++ }
++ if (isSuperInterface(i, intf)) {
++ return true;
++ }
++ }
++ return false;
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8017196-ensure_proxies_are_handled_appropriately.patch b/java/openjdk6/files/icedtea/openjdk/8017196-ensure_proxies_are_handled_appropriately.patch
new file mode 100644
index 000000000000..4208d24006b3
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8017196-ensure_proxies_are_handled_appropriately.patch
@@ -0,0 +1,94 @@
+# HG changeset patch
+# User mchung
+# Date 1374193345 25200
+# Thu Jul 18 17:22:25 2013 -0700
+# Node ID 2a415f9ee0976719ac79e6e5e2b1f00b29636427
+# Parent 9e7e1b6ab5cdf0096c9c16d991e6a982771a15f1
+8017196: Ensure Proxies are handled appropriately
+Reviewed-by: dfuchs, jrose, jdn, ahgross, chegar
+
+diff -r 9e7e1b6ab5cd -r 2a415f9ee097 src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java
+--- corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java Tue Oct 15 15:24:25 2013 +0100
++++ corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java Thu Jul 18 17:22:25 2013 -0700
+@@ -43,6 +43,8 @@
+ import com.sun.corba.se.spi.orbutil.proxy.DelegateInvocationHandlerImpl ;
+ import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandler ;
+ import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandlerImpl ;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
+
+ public class InvocationHandlerFactoryImpl implements InvocationHandlerFactory
+ {
+@@ -114,24 +116,32 @@
+ // which extends org.omg.CORBA.Object. This handler delegates all
+ // calls directly to a DynamicStubImpl, which extends
+ // org.omg.CORBA.portable.ObjectImpl.
+- InvocationHandler dynamicStubHandler =
++ final InvocationHandler dynamicStubHandler =
+ DelegateInvocationHandlerImpl.create( stub ) ;
+
+ // Create an invocation handler that handles any remote interface
+ // methods.
+- InvocationHandler stubMethodHandler = new StubInvocationHandlerImpl(
++ final InvocationHandler stubMethodHandler = new StubInvocationHandlerImpl(
+ pm, classData, stub ) ;
+
+ // Create a composite handler that handles the DynamicStub interface
+ // as well as the remote interfaces.
+ final CompositeInvocationHandler handler =
+ new CustomCompositeInvocationHandlerImpl( stub ) ;
++
++ AccessController.doPrivileged(new PrivilegedAction<Void>() {
++ @Override
++ public Void run() {
+ handler.addInvocationHandler( DynamicStub.class,
+ dynamicStubHandler ) ;
+ handler.addInvocationHandler( org.omg.CORBA.Object.class,
+ dynamicStubHandler ) ;
+ handler.addInvocationHandler( Object.class,
+ dynamicStubHandler ) ;
++ return null;
++ }
++ });
++
+
+ // If the method passed to invoke is not from DynamicStub or its superclasses,
+ // it must be from an implemented interface, so we just handle
+diff -r 9e7e1b6ab5cd -r 2a415f9ee097 src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java
+--- corba/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java Tue Oct 15 15:24:25 2013 +0100
++++ corba/src/share/classes/com/sun/corba/se/spi/orbutil/proxy/CompositeInvocationHandlerImpl.java Thu Jul 18 17:22:25 2013 -0700
+@@ -36,6 +36,7 @@
+
+ import com.sun.corba.se.spi.logging.CORBALogDomains ;
+ import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
++import com.sun.corba.se.impl.presentation.rmi.DynamicAccessPermission;
+
+ public class CompositeInvocationHandlerImpl implements
+ CompositeInvocationHandler
+@@ -46,11 +47,13 @@
+ public void addInvocationHandler( Class interf,
+ InvocationHandler handler )
+ {
++ checkAccess();
+ classToInvocationHandler.put( interf, handler ) ;
+ }
+
+ public void setDefaultHandler( InvocationHandler handler )
+ {
++ checkAccess();
+ defaultHandler = handler ;
+ }
+
+@@ -78,4 +81,12 @@
+
+ return handler.invoke( proxy, method, args ) ;
+ }
++
++ private static final DynamicAccessPermission perm = new DynamicAccessPermission("access");
++ private void checkAccess() {
++ final SecurityManager sm = System.getSecurityManager();
++ if (sm != null) {
++ sm.checkPermission(perm);
+ }
++ }
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8017287-better_resource_disposal.patch b/java/openjdk6/files/icedtea/openjdk/8017287-better_resource_disposal.patch
new file mode 100644
index 000000000000..135085592aed
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8017287-better_resource_disposal.patch
@@ -0,0 +1,22 @@
+# HG changeset patch
+# User bae
+# Date 1382732366 -3600
+# Fri Oct 25 21:19:26 2013 +0100
+# Node ID 768afb4062fb6653278e5f7e5304a623fcd80c9c
+# Parent 43b600fed0e8ac9d5ffe7556617d4850143e2dcd
+8017287: Better resource disposal
+Reviewed-by: vadim
+
+diff -r 43b600fed0e8 -r 768afb4062fb src/share/classes/sun/java2d/Disposer.java
+--- jdk/src/share/classes/sun/java2d/Disposer.java Fri Oct 25 21:01:28 2013 +0100
++++ jdk/src/share/classes/sun/java2d/Disposer.java Fri Oct 25 21:19:26 2013 +0100
+@@ -147,8 +147,7 @@
+ obj = null;
+ rec = null;
+ } catch (Exception e) {
+- System.out.println("Exception while removing reference: " + e);
+- e.printStackTrace();
++ System.out.println("Exception while removing reference.");
+ }
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8017291-cast_proxies_aside.patch b/java/openjdk6/files/icedtea/openjdk/8017291-cast_proxies_aside.patch
new file mode 100644
index 000000000000..e030a78170dc
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8017291-cast_proxies_aside.patch
@@ -0,0 +1,34 @@
+# HG changeset patch
+# User mchung
+# Date 1373884816 25200
+# Mon Jul 15 03:40:16 2013 -0700
+# Node ID 011d86bdcbf8d4fe0016351b775ff1f48f3620a1
+# Parent 768afb4062fb6653278e5f7e5304a623fcd80c9c
+8017291: Cast Proxies Aside
+Reviewed-by: alanb, ahgross
+
+diff -r 768afb4062fb -r 011d86bdcbf8 src/share/classes/java/lang/ClassLoader.java
+--- jdk/src/share/classes/java/lang/ClassLoader.java Fri Oct 25 21:19:26 2013 +0100
++++ jdk/src/share/classes/java/lang/ClassLoader.java Mon Jul 15 03:40:16 2013 -0700
+@@ -54,6 +54,7 @@
+ import sun.misc.VM;
+ import sun.reflect.CallerSensitive;
+ import sun.reflect.Reflection;
++import sun.reflect.misc.ReflectUtil;
+ import sun.security.util.SecurityConstants;
+
+ /**
+@@ -338,6 +339,13 @@
+ private void checkPackageAccess(Class cls, ProtectionDomain pd) {
+ final SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
++ if (ReflectUtil.isNonPublicProxyClass(cls)) {
++ for (Class intf: cls.getInterfaces()) {
++ checkPackageAccess(intf, pd);
++ }
++ return;
++ }
++
+ final String name = cls.getName();
+ final int i = name.lastIndexOf('.');
+ if (i != -1) {
diff --git a/java/openjdk6/files/icedtea/openjdk/8017298-better_xml_support.patch b/java/openjdk6/files/icedtea/openjdk/8017298-better_xml_support.patch
new file mode 100644
index 000000000000..a4baf6b8d326
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8017298-better_xml_support.patch
@@ -0,0 +1,999 @@
+# HG changeset patch
+# User joehw
+# Date 1383031104 0
+# Tue Oct 29 07:18:24 2013 +0000
+# Node ID 3dc769c632a1d6a8f69d2857b3c13c43a83481be
+# Parent 7799c3bd00f5a4fda6448cb8bcd7768c66ec166d
+8017298: Better XML support
+Reviewed-by: alanb, dfuchs, mullan
+
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Tue Oct 29 07:18:24 2013 +0000
+@@ -50,8 +50,8 @@
+ import com.sun.org.apache.xerces.internal.xni.Augmentations;
+ import com.sun.org.apache.xerces.internal.impl.Constants;
+ import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+ import javax.xml.stream.XMLStreamConstants;
+ import javax.xml.stream.events.XMLEvent;
+@@ -350,7 +350,7 @@
+
+ protected boolean foundBuiltInRefs = false;
+
+- protected SecurityManager fSecurityManager = null;
++ protected XMLSecurityManager fSecurityManager = null;
+
+ //skip element algorithm
+ static final short MAX_DEPTH_LIMIT = 5 ;
+@@ -555,11 +555,13 @@
+ }
+
+ try {
+- fSecurityManager = (SecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER);
++ fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER);
+ } catch (XMLConfigurationException e) {
+ fSecurityManager = null;
+ }
+- fElementAttributeLimit = (fSecurityManager != null)?fSecurityManager.getElementAttrLimit():0;
++ fElementAttributeLimit = (fSecurityManager != null)?
++ fSecurityManager.getLimit(XMLSecurityManager.Limit.ELEMENT_ATTRIBUTE_LIMIT):0;
++
+
+ try {
+ fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS);
+@@ -929,6 +931,7 @@
+
+ // scan decl
+ super.scanXMLDeclOrTextDecl(scanningTextDecl, fStrings);
++
+ fMarkupDepth--;
+
+ // pseudo-attribute values
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Tue Oct 29 07:18:24 2013 +0000
+@@ -64,8 +64,8 @@
+ import com.sun.org.apache.xerces.internal.xinclude.XIncludeHandler;
+
+ import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.URI;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+
+
+ /**
+@@ -321,7 +321,7 @@
+
+ // stores defaults for entity expansion limit if it has
+ // been set on the configuration.
+- protected SecurityManager fSecurityManager = null;
++ protected XMLSecurityManager fSecurityManager = null;
+
+ /**
+ * True if the document entity is standalone. This should really
+@@ -1531,7 +1531,7 @@
+ fValidationManager = null;
+ }
+ try {
+- fSecurityManager = (SecurityManager)componentManager.getProperty(SECURITY_MANAGER);
++ fSecurityManager = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER);
+ }
+ catch (XMLConfigurationException e) {
+ fSecurityManager = null;
+@@ -1549,7 +1549,9 @@
+ // a class acting as a component manager but not
+ // implementing that interface for whatever reason.
+ public void reset() {
+- fEntityExpansionLimit = (fSecurityManager != null)?fSecurityManager.getEntityExpansionLimit():0;
++ fEntityExpansionLimit = (fSecurityManager != null)?
++ fSecurityManager.getLimit(XMLSecurityManager.Limit.ENTITY_EXPANSION_LIMIT):0;
++
+
+ // initialize state
+ fStandalone = false;
+@@ -1689,8 +1691,9 @@
+ }
+ if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
+ propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
+- fSecurityManager = (SecurityManager)value;
+- fEntityExpansionLimit = (fSecurityManager != null)?fSecurityManager.getEntityExpansionLimit():0;
++ fSecurityManager = (XMLSecurityManager)value;
++ fEntityExpansionLimit = (fSecurityManager != null)?
++ fSecurityManager.getLimit(XMLSecurityManager.Limit.ENTITY_EXPANSION_LIMIT):0;
+ }
+ }
+
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Tue Oct 29 07:18:24 2013 +0000
+@@ -515,7 +515,7 @@
+ reportFatalError("SDDeclInvalid", new Object[] {standalone});
+ }
+ } else {
+- reportFatalError("EncodingDeclRequired", null);
++ reportFatalError("SDDeclNameInvalid", null);
+ }
+ break;
+ }
+@@ -580,7 +580,7 @@
+ XMLString value)
+ throws IOException, XNIException {
+
+- String name = fEntityScanner.scanName();
++ String name = scanPseudoAttributeName();
+ // XMLEntityManager.print(fEntityManager.getCurrentEntity());
+
+ if (name == null) {
+@@ -633,6 +633,35 @@
+ } // scanPseudoAttribute(XMLString):String
+
+ /**
++ * Scans the name of a pseudo attribute. The only legal names
++ * in XML 1.0/1.1 documents are 'version', 'encoding' and 'standalone'.
++ *
++ * @return the name of the pseudo attribute or <code>null</code>
++ * if a legal pseudo attribute name could not be scanned.
++ */
++ private String scanPseudoAttributeName() throws IOException, XNIException {
++ final int ch = fEntityScanner.peekChar();
++ switch (ch) {
++ case 'v':
++ if (fEntityScanner.skipString(fVersionSymbol)) {
++ return fVersionSymbol;
++ }
++ break;
++ case 'e':
++ if (fEntityScanner.skipString(fEncodingSymbol)) {
++ return fEncodingSymbol;
++ }
++ break;
++ case 's':
++ if (fEntityScanner.skipString(fStandaloneSymbol)) {
++ return fStandaloneSymbol;
++ }
++ break;
++ }
++ return null;
++ } // scanPseudoAttributeName()
++
++ /**
+ * Scans a processing instruction.
+ * <p>
+ * <pre>
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Tue Oct 29 07:18:24 2013 +0000
+@@ -43,6 +43,7 @@
+
+ # 2.9 Standalone Document Declaration
+ SDDeclInvalid = The standalone document declaration value must be \"yes\" or \"no\", not \"{0}\".
++ SDDeclNameInvalid = The standalone name in XML declaration may be misspelled.
+ # 2.12 Language Identification
+ XMLLangInvalid = The xml:lang attribute value \"{0}\" is an invalid language identifier.
+ # 3. Logical Structures
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java Tue Oct 29 07:18:24 2013 +0000
+@@ -21,13 +21,13 @@
+
+ package com.sun.org.apache.xerces.internal.impl.xs.models;
+
++import com.sun.org.apache.xerces.internal.impl.Constants;
+ import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
++import com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode;
++import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager ;
+-import com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
+-import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
+-import com.sun.org.apache.xerces.internal.impl.Constants;
+
+ /**
+ *
+@@ -68,7 +68,7 @@
+
+ // stores defaults for different security holes (maxOccurLimit in current context) if it has
+ // been set on the configuration.
+- private SecurityManager fSecurityManager = null;
++ private XMLSecurityManager fSecurityManager = null;
+
+ /** default constructor */
+ public CMNodeFactory() {
+@@ -77,10 +77,10 @@
+ public void reset(XMLComponentManager componentManager){
+ fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
+ try {
+- fSecurityManager = (SecurityManager)componentManager.getProperty(SECURITY_MANAGER);
++ fSecurityManager = (XMLSecurityManager)componentManager.getProperty(SECURITY_MANAGER);
+ //we are setting the limit of number of nodes to 3times the maxOccur value..
+ if(fSecurityManager != null){
+- maxNodeLimit = fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY ;
++ maxNodeLimit = fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY ;
+ }
+ }
+ catch (XMLConfigurationException e) {
+@@ -152,8 +152,9 @@
+
+ if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
+ propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
+- fSecurityManager = (SecurityManager)value;
+- maxNodeLimit = (fSecurityManager != null) ? fSecurityManager.getMaxOccurNodeLimit() * MULTIPLICITY : 0 ;
++ fSecurityManager = (XMLSecurityManager)value;
++ maxNodeLimit = (fSecurityManager != null) ?
++ fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY : 0 ;
+ return;
+ }
+ if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Tue Oct 29 07:18:24 2013 +0000
+@@ -38,6 +38,7 @@
+ import com.sun.org.apache.xerces.internal.util.DOMUtil;
+ import com.sun.org.apache.xerces.internal.util.SymbolTable;
+ import com.sun.org.apache.xerces.internal.util.XMLSymbols;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.QName;
+ import com.sun.org.apache.xerces.internal.xs.XSConstants;
+ import org.w3c.dom.Attr;
+@@ -1235,7 +1236,7 @@
+ if (!optimize) {
+ //Revisit :: IMO this is not right place to check
+ // maxOccurNodeLimit.
+- int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getMaxOccurNodeLimit();
++ int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT);
+ if (max > maxOccurNodeLimit) {
+ reportSchemaFatalError("maxOccurLimit", new Object[] {new Integer(maxOccurNodeLimit)}, element);
+
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java Tue Oct 29 07:18:24 2013 +0000
+@@ -56,10 +56,10 @@
+ import com.sun.org.apache.xerces.internal.util.DOMInputSource;
+ import com.sun.org.apache.xerces.internal.util.DefaultErrorHandler;
+ import com.sun.org.apache.xerces.internal.util.SAXInputSource;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.SymbolTable;
+ import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+ import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.QName;
+ import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
+ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
+@@ -210,7 +210,7 @@
+ *
+ * <p>Protected to allow access by any traverser.</p>
+ */
+- protected SecurityManager fSecureProcessing = null;
++ protected XMLSecurityManager fSecureProcessing = null;
+
+
+ // These tables correspond to the symbol spaces defined in the
+@@ -1963,7 +1963,7 @@
+ fSecureProcessing = null;
+ if( componentManager!=null ) {
+ try {
+- fSecureProcessing = (SecurityManager) componentManager.getProperty(SECURE_PROCESSING);
++ fSecureProcessing = (XMLSecurityManager) componentManager.getProperty(SECURE_PROCESSING);
+ } catch (XMLConfigurationException xmlConfigurationException) {
+ ;
+ }
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Tue Oct 29 07:18:24 2013 +0000
+@@ -34,7 +34,7 @@
+ import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator;
+ import com.sun.org.apache.xerces.internal.jaxp.validation.XSGrammarPoolContainer;
+ import com.sun.org.apache.xerces.internal.parsers.DOMParser;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
+@@ -153,7 +153,7 @@
+
+ // If the secure processing feature is on set a security manager.
+ if (secureProcessing) {
+- domParser.setProperty(SECURITY_MANAGER, new SecurityManager());
++ domParser.setProperty(SECURITY_MANAGER, new XMLSecurityManager());
+ }
+
+ this.grammar = dbf.getSchema();
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Tue Oct 29 07:18:24 2013 +0000
+@@ -36,7 +36,7 @@
+ import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter;
+ import com.sun.org.apache.xerces.internal.jaxp.validation.XSGrammarPoolContainer;
+ import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
+@@ -143,7 +143,7 @@
+
+ // If the secure processing feature is on set a security manager.
+ if (secureProcessing) {
+- xmlReader.setProperty0(SECURITY_MANAGER, new SecurityManager());
++ xmlReader.setProperty0(SECURITY_MANAGER, new XMLSecurityManager());
+ }
+
+ // Set application's features, followed by validation features.
+@@ -349,7 +349,7 @@
+ }
+ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+ try {
+- setProperty(SECURITY_MANAGER, value ? new SecurityManager() : null);
++ setProperty(SECURITY_MANAGER, value ? new XMLSecurityManager() : null);
+ }
+ catch (SAXNotRecognizedException exc) {
+ // If the property is not supported
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java Tue Oct 29 07:18:24 2013 +0000
+@@ -24,7 +24,7 @@
+ import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
+ import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
+ import com.sun.org.apache.xerces.internal.parsers.XML11Configuration;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.XNIException;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
+@@ -167,7 +167,7 @@
+ private XMLParserConfiguration initialize() {
+ XML11Configuration config = new XML11Configuration();
+ if (fComponentManager.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+- config.setProperty(SECURITY_MANAGER, new SecurityManager());
++ config.setProperty(SECURITY_MANAGER, new XMLSecurityManager());
+ }
+ config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER));
+ config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER));
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java Tue Oct 29 07:18:24 2013 +0000
+@@ -47,10 +47,10 @@
+ import com.sun.org.apache.xerces.internal.util.SAXLocatorWrapper;
+ import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
+ import com.sun.org.apache.xerces.internal.util.SymbolTable;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.URI;
+ import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
+ import com.sun.org.apache.xerces.internal.util.XMLSymbols;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.Augmentations;
+ import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+ import com.sun.org.apache.xerces.internal.xni.QName;
+@@ -677,7 +677,7 @@
+ reader = spf.newSAXParser().getXMLReader();
+ // If this is a Xerces SAX parser, set the security manager if there is one
+ if (reader instanceof com.sun.org.apache.xerces.internal.parsers.SAXParser) {
+- SecurityManager securityManager = (SecurityManager) fComponentManager.getProperty(SECURITY_MANAGER);
++ XMLSecurityManager securityManager = (XMLSecurityManager) fComponentManager.getProperty(SECURITY_MANAGER);
+ if (securityManager != null) {
+ try {
+ reader.setProperty(SECURITY_MANAGER, securityManager);
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 07:18:24 2013 +0000
+@@ -39,8 +39,8 @@
+ import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
+ import com.sun.org.apache.xerces.internal.util.SAXInputSource;
+ import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.XNIException;
+ import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
+ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
+@@ -74,7 +74,7 @@
+ private static final String XMLGRAMMAR_POOL =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
+
+- /** Property identifier: SecurityManager. */
++ /** Property identifier: XMLSecurityManager. */
+ private static final String SECURITY_MANAGER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
+
+@@ -97,8 +97,8 @@
+ /** The ErrorHandlerWrapper */
+ private ErrorHandlerWrapper fErrorHandlerWrapper;
+
+- /** The SecurityManager. */
+- private SecurityManager fSecurityManager;
++ /** The XMLSecurityManager. */
++ private XMLSecurityManager fSecurityManager;
+
+ /** The container for the real grammar pool. */
+ private XMLGrammarPoolWrapper fXMLGrammarPoolWrapper;
+@@ -113,7 +113,7 @@
+ fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper);
+
+ // Enable secure processing feature by default
+- fSecurityManager = new SecurityManager();
++ fSecurityManager = new XMLSecurityManager();
+ fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
+ }
+
+@@ -321,7 +321,7 @@
+ SAXMessageFormatter.formatMessage(null,
+ "jaxp-secureprocessing-feature", null));
+ }
+- fSecurityManager = value ? new SecurityManager() : null;
++ fSecurityManager = value ? new XMLSecurityManager() : null;
+ fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
+ return;
+ }
+@@ -350,7 +350,7 @@
+ "ProperyNameNull", null));
+ }
+ if (name.equals(SECURITY_MANAGER)) {
+- fSecurityManager = (SecurityManager) object;
++ fSecurityManager = (XMLSecurityManager) object;
+ fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
+ return;
+ }
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Tue Oct 29 07:18:24 2013 +0000
+@@ -37,8 +37,8 @@
+ import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
+ import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
+ import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.SymbolTable;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+ import com.sun.org.apache.xerces.internal.xni.XNIException;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
+@@ -173,7 +173,7 @@
+ private final HashMap fInitProperties = new HashMap();
+
+ /** Stores the initial security manager. */
+- private final SecurityManager fInitSecurityManager;
++ private final XMLSecurityManager fInitSecurityManager;
+
+ //
+ // User Objects
+@@ -212,7 +212,7 @@
+
+ if (System.getSecurityManager() != null) {
+ _isSecureMode = true;
+- setProperty(SECURITY_MANAGER, new SecurityManager());
++ setProperty(SECURITY_MANAGER, new XMLSecurityManager());
+ } else {
+ fComponents.put(SECURITY_MANAGER, null);
+ }
+@@ -233,7 +233,7 @@
+ // if the secure processing feature is set to true, add a security manager to the configuration
+ Boolean secureProcessing = grammarContainer.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
+ if (Boolean.TRUE.equals(secureProcessing)) {
+- fInitSecurityManager = new SecurityManager();
++ fInitSecurityManager = new XMLSecurityManager();
+ }
+ else {
+ fInitSecurityManager = null;
+@@ -296,7 +296,7 @@
+ if (_isSecureMode && !value) {
+ throw new XMLConfigurationException(XMLConfigurationException.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING);
+ }
+- setProperty(SECURITY_MANAGER, value ? new SecurityManager() : null);
++ setProperty(SECURITY_MANAGER, value ? new XMLSecurityManager() : null);
+ return;
+ }
+ fConfigUpdated = true;
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java Tue Oct 29 07:18:24 2013 +0000
+@@ -25,9 +25,9 @@
+ import com.sun.org.apache.xerces.internal.util.EntityResolverWrapper;
+ import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
+ import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.SymbolHash;
+ import com.sun.org.apache.xerces.internal.util.XMLSymbols;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.Augmentations;
+ import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+ import com.sun.org.apache.xerces.internal.xni.QName;
+@@ -1649,7 +1649,7 @@
+ else if (featureId.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+ if (state) {
+ if (fConfiguration.getProperty(SECURITY_MANAGER )==null) {
+- fConfiguration.setProperty(SECURITY_MANAGER, new SecurityManager());
++ fConfiguration.setProperty(SECURITY_MANAGER, new XMLSecurityManager());
+ }
+ }
+ }
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java Tue Oct 29 07:18:24 2013 +0000
+@@ -23,8 +23,8 @@
+ import com.sun.org.apache.xerces.internal.impl.Constants;
+ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.SymbolTable;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+
+ /**
+ * This configuration allows Xerces to behave in a security-conscious manner; that is,
+@@ -106,8 +106,8 @@
+ XMLComponentManager parentSettings) {
+ super(symbolTable, grammarPool, parentSettings);
+
+- // create the SecurityManager property:
+- setProperty(SECURITY_MANAGER_PROPERTY, new SecurityManager());
++ // create the XMLSecurityManager property:
++ setProperty(SECURITY_MANAGER_PROPERTY, new XMLSecurityManager());
+ } // <init>(SymbolTable,XMLGrammarPool)
+
+ } // class SecurityConfiguration
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SecurityManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SecurityManager.java Tue Oct 29 05:50:44 2013 +0000
++++ /dev/null Thu Jan 01 00:00:00 1970 +0000
+@@ -1,226 +0,0 @@
+-/*
+- * reserved comment block
+- * DO NOT REMOVE OR ALTER!
+- */
+-/*
+- * The Apache Software License, Version 1.1
+- *
+- *
+- * Copyright (c) 2003 The Apache Software Foundation.
+- * All rights reserved.
+- *
+- * Redistribution and use in source and binary forms, with or without
+- * modification, are permitted provided that the following conditions
+- * are met:
+- *
+- * 1. Redistributions of source code must retain the above copyright
+- * notice, this list of conditions and the following disclaimer.
+- *
+- * 2. Redistributions in binary form must reproduce the above copyright
+- * notice, this list of conditions and the following disclaimer in
+- * the documentation and/or other materials provided with the
+- * distribution.
+- *
+- * 3. The end-user documentation included with the redistribution,
+- * if any, must include the following acknowledgment:
+- * "This product includes software developed by the
+- * Apache Software Foundation (http://www.apache.org/)."
+- * Alternately, this acknowledgment may appear in the software itself,
+- * if and wherever such third-party acknowledgments normally appear.
+- *
+- * 4. The names "Xerces" and "Apache Software Foundation" must
+- * not be used to endorse or promote products derived from this
+- * software without prior written permission. For written
+- * permission, please contact apache@apache.org.
+- *
+- * 5. Products derived from this software may not be called "Apache",
+- * nor may "Apache" appear in their name, without prior written
+- * permission of the Apache Software Foundation.
+- *
+- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+- * SUCH DAMAGE.
+- * ====================================================================
+- *
+- * This software consists of voluntary contributions made by many
+- * individuals on behalf of the Apache Software Foundation and was
+- * originally based on software copyright (c) 1999, International
+- * Business Machines, Inc., http://www.apache.org. For more
+- * information on the Apache Software Foundation, please see
+- * <http://www.apache.org/>.
+- */
+-
+-package com.sun.org.apache.xerces.internal.util;
+-import com.sun.org.apache.xerces.internal.impl.Constants;
+-import java.security.AccessController;
+-import java.security.PrivilegedAction;
+-/**
+- * This class is a container for parser settings that relate to
+- * security, or more specifically, it is intended to be used to prevent denial-of-service
+- * attacks from being launched against a system running Xerces.
+- * Any component that is aware of a denial-of-service attack that can arise
+- * from its processing of a certain kind of document may query its Component Manager
+- * for the property (http://apache.org/xml/properties/security-manager)
+- * whose value will be an instance of this class.
+- * If no value has been set for the property, the component should proceed in the "usual" (spec-compliant)
+- * manner. If a value has been set, then it must be the case that the component in
+- * question needs to know what method of this class to query. This class
+- * will provide defaults for all known security issues, but will also provide
+- * setters so that those values can be tailored by applications that care.
+- *
+- * @author Neil Graham, IBM
+- *
+- * @version $Id: SecurityManager.java,v 1.5 2010-11-01 04:40:14 joehw Exp $
+- */
+-public final class SecurityManager {
+-
+- //
+- // Constants
+- //
+-
+- // default value for entity expansion limit
+- private final static int DEFAULT_ENTITY_EXPANSION_LIMIT = 64000;
+-
+- /** Default value of number of nodes created. **/
+- private final static int DEFAULT_MAX_OCCUR_NODE_LIMIT = 5000;
+-
+- //
+- // Data
+- //
+-
+- private final static int DEFAULT_ELEMENT_ATTRIBUTE_LIMIT = 10000;
+-
+- /** Entity expansion limit. **/
+- private int entityExpansionLimit;
+-
+- /** W3C XML Schema maxOccurs limit. **/
+- private int maxOccurLimit;
+-
+- private int fElementAttributeLimit;
+- // default constructor. Establishes default values for
+- // all known security holes.
+- /**
+- * Default constructor. Establishes default values
+- * for known security vulnerabilities.
+- */
+- public SecurityManager() {
+- entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
+- maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT ;
+- fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
+- //We are reading system properties only once ,
+- //at the time of creation of this object ,
+- readSystemProperties();
+- }
+-
+- /**
+- * <p>Sets the number of entity expansions that the
+- * parser should permit in a document.</p>
+- *
+- * @param limit the number of entity expansions
+- * permitted in a document
+- */
+- public void setEntityExpansionLimit(int limit) {
+- entityExpansionLimit = limit;
+- }
+-
+- /**
+- * <p>Returns the number of entity expansions
+- * that the parser permits in a document.</p>
+- *
+- * @return the number of entity expansions
+- * permitted in a document
+- */
+- public int getEntityExpansionLimit() {
+- return entityExpansionLimit;
+- }
+-
+- /**
+- * <p>Sets the limit of the number of content model nodes
+- * that may be created when building a grammar for a W3C
+- * XML Schema that contains maxOccurs attributes with values
+- * other than "unbounded".</p>
+- *
+- * @param limit the maximum value for maxOccurs other
+- * than "unbounded"
+- */
+- public void setMaxOccurNodeLimit(int limit){
+- maxOccurLimit = limit;
+- }
+-
+- /**
+- * <p>Returns the limit of the number of content model nodes
+- * that may be created when building a grammar for a W3C
+- * XML Schema that contains maxOccurs attributes with values
+- * other than "unbounded".</p>
+- *
+- * @return the maximum value for maxOccurs other
+- * than "unbounded"
+- */
+- public int getMaxOccurNodeLimit(){
+- return maxOccurLimit;
+- }
+-
+- public int getElementAttrLimit(){
+- return fElementAttributeLimit;
+- }
+-
+- public void setElementAttrLimit(int limit){
+- fElementAttributeLimit = limit;
+- }
+-
+- private void readSystemProperties(){
+-
+- //TODO: also read SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT
+- try {
+- String value = getSystemProperty(Constants.ENTITY_EXPANSION_LIMIT);
+- if(value != null && !value.equals("")){
+- entityExpansionLimit = Integer.parseInt(value);
+- if (entityExpansionLimit < 0)
+- entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
+- }
+- else
+- entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
+- }catch(Exception ex){}
+-
+- try {
+- String value = getSystemProperty(Constants.MAX_OCCUR_LIMIT);
+- if(value != null && !value.equals("")){
+- maxOccurLimit = Integer.parseInt(value);
+- if (maxOccurLimit < 0)
+- maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
+- }
+- else
+- maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
+- }catch(Exception ex){}
+-
+- try {
+- String value = getSystemProperty(Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT);
+- if(value != null && !value.equals("")){
+- fElementAttributeLimit = Integer.parseInt(value);
+- if ( fElementAttributeLimit < 0)
+- fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
+- }
+- else
+- fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
+-
+- }catch(Exception ex){}
+-
+- }
+-
+- private String getSystemProperty(final String propName) {
+- return AccessController.doPrivileged(new PrivilegedAction<String>() {
+- public String run() {
+- return System.getProperty(propName);
+- }
+- });
+- }
+-} // class SecurityManager
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SymbolTable.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SymbolTable.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SymbolTable.java Tue Oct 29 07:18:24 2013 +0000
+@@ -173,7 +173,7 @@
+ for (int i = 0; i < length; i++) {
+ code = code * 37 + symbol.charAt(i);
+ }
+- return code & 0x7FFFFFF;
++ return code & 0x7FFFFFFF;
+
+ } // hash(String):int
+
+@@ -194,7 +194,7 @@
+ for (int i = 0; i < length; i++) {
+ code = code * 37 + buffer[offset + i];
+ }
+- return code & 0x7FFFFFF;
++ return code & 0x7FFFFFFF;
+
+ } // hash(char[],int,int):int
+
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Tue Oct 29 07:18:24 2013 +0000
+@@ -0,0 +1,147 @@
++/*
++ * 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 com.sun.org.apache.xerces.internal.utils;
++
++import com.sun.org.apache.xerces.internal.impl.Constants;
++
++/**
++ * This class manages standard and implementation-specific limitations.
++ *
++ */
++public final class XMLSecurityManager {
++
++ /**
++ * States of the settings of a property, in the order: default value, value
++ * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system
++ * properties, and jaxp api properties
++ */
++ public static enum State {
++ //this order reflects the overriding order
++ DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY
++ }
++
++ /**
++ * Limits managed by the security manager
++ */
++ public static enum Limit {
++ ENTITY_EXPANSION_LIMIT(64000),
++ MAX_OCCUR_NODE_LIMIT(5000),
++ ELEMENT_ATTRIBUTE_LIMIT(10000);
++
++ final int defaultValue;
++
++ Limit(int value) {
++ this.defaultValue = value;
++ }
++
++ int defaultValue() {
++ return defaultValue;
++ }
++ }
++
++ /**
++ * Values of the limits as defined in enum Limit
++ */
++ private final int[] limits;
++ /**
++ * States of the settings for each limit in limits above
++ */
++ private State[] states = {State.DEFAULT, State.DEFAULT, State.DEFAULT, State.DEFAULT};
++
++ /**
++ * Default constructor. Establishes default values for known security
++ * vulnerabilities.
++ */
++ public XMLSecurityManager() {
++ limits = new int[Limit.values().length];
++ for (Limit limit : Limit.values()) {
++ limits[limit.ordinal()] = limit.defaultValue();
++ }
++ //read system properties or jaxp.properties
++ readSystemProperties();
++ }
++
++ /**
++ * Sets the limit for a specific type of XML constructs. This can be either
++ * the size or the number of the constructs.
++ *
++ * @param type the type of limitation
++ * @param state the state of limitation
++ * @param limit the limit to the type
++ */
++ public void setLimit(Limit limit, State state, int value) {
++ //only update if it shall override
++ if (state.compareTo(states[limit.ordinal()]) >= 0) {
++ limits[limit.ordinal()] = value;
++ states[limit.ordinal()] = state;
++ }
++ }
++
++ /**
++ * Returns the limit set for the type specified
++ *
++ * @param limit the type of limitation
++ * @return the limit to the type
++ */
++ public int getLimit(Limit limit) {
++ return limits[limit.ordinal()];
++ }
++
++ /**
++ * Read from system properties, or those in jaxp.properties
++ */
++ private void readSystemProperties() {
++ getSystemProperty(Limit.ENTITY_EXPANSION_LIMIT, Constants.ENTITY_EXPANSION_LIMIT);
++ getSystemProperty(Limit.MAX_OCCUR_NODE_LIMIT, Constants.MAX_OCCUR_LIMIT);
++ getSystemProperty(Limit.ELEMENT_ATTRIBUTE_LIMIT,
++ Constants.SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT);
++ }
++
++ /**
++ * Read from system properties, or those in jaxp.properties
++ *
++ * @param limit the type of the property
++ * @param property the property name
++ */
++ private void getSystemProperty(Limit limit, String property) {
++ try {
++ String value = SecuritySupport.getSystemProperty(property);
++ if (value != null && !value.equals("")) {
++ limits[limit.ordinal()] = Integer.parseInt(value);
++ states[limit.ordinal()] = State.SYSTEMPROPERTY;
++ return;
++ }
++
++ value = SecuritySupport.readJAXPProperty(property);
++ if (value != null && !value.equals("")) {
++ limits[limit.ordinal()] = Integer.parseInt(value);
++ states[limit.ordinal()] = State.JAXPDOTPROPERTIES;
++ }
++ } catch (NumberFormatException e) {
++ //invalid setting ignored
++ }
++ }
++}
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java Tue Oct 29 07:18:24 2013 +0000
+@@ -36,7 +36,6 @@
+ import com.sun.org.apache.xerces.internal.util.HTTPInputSource;
+ import com.sun.org.apache.xerces.internal.util.IntStack;
+ import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
+-import com.sun.org.apache.xerces.internal.util.SecurityManager;
+ import com.sun.org.apache.xerces.internal.util.SymbolTable;
+ import com.sun.org.apache.xerces.internal.util.URI;
+ import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
+@@ -44,6 +43,7 @@
+ import com.sun.org.apache.xerces.internal.util.XMLChar;
+ import com.sun.org.apache.xerces.internal.util.XMLSymbols;
+ import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.Augmentations;
+ import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
+ import com.sun.org.apache.xerces.internal.xni.QName;
+@@ -280,7 +280,7 @@
+ protected SymbolTable fSymbolTable;
+ protected XMLErrorReporter fErrorReporter;
+ protected XMLEntityResolver fEntityResolver;
+- protected SecurityManager fSecurityManager;
++ protected XMLSecurityManager fSecurityManager;
+
+ // these are needed for text include processing
+ protected XIncludeTextReader fXInclude10TextReader;
+@@ -506,8 +506,8 @@
+
+ // Get security manager.
+ try {
+- SecurityManager value =
+- (SecurityManager)componentManager.getProperty(
++ XMLSecurityManager value =
++ (XMLSecurityManager)componentManager.getProperty(
+ SECURITY_MANAGER);
+
+ if (value != null) {
+@@ -656,7 +656,7 @@
+ return;
+ }
+ if (propertyId.equals(SECURITY_MANAGER)) {
+- fSecurityManager = (SecurityManager)value;
++ fSecurityManager = (XMLSecurityManager)value;
+ if (fChildConfig != null) {
+ fChildConfig.setProperty(propertyId, value);
+ }
+diff -r 7799c3bd00f5 -r 3dc769c632a1 drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Tue Oct 29 05:50:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Tue Oct 29 07:18:24 2013 +0000
+@@ -248,7 +248,7 @@
+ public int fBufferSize = DEFAULT_BUFFER_SIZE;
+
+ /** Default buffer size before we've finished with the XMLDecl: */
+- public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 28;
++ public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
+
+ /** Default internal entity buffer size (1024). */
+ public static final int DEFAULT_INTERNAL_BUFFER_SIZE = 1024;
diff --git a/java/openjdk6/files/icedtea/openjdk/8017300-improve_interface_implementation.patch b/java/openjdk6/files/icedtea/openjdk/8017300-improve_interface_implementation.patch
new file mode 100644
index 000000000000..29a20dbda079
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8017300-improve_interface_implementation.patch
@@ -0,0 +1,129 @@
+# HG changeset patch
+# User sundar
+# Date 1382737389 -3600
+# Fri Oct 25 22:43:09 2013 +0100
+# Node ID de490a43861e05f3da489db136687b1dc6f1949a
+# Parent 0b0490779c5b643b7a3e90ac6870c1ee4bd5a155
+8017300: Improve Interface Implementation
+Reviewed-by: ahgross, jlaskey, mchung
+
+diff -r 0b0490779c5b -r de490a43861e src/share/classes/com/sun/script/util/InterfaceImplementor.java
+--- jdk/src/share/classes/com/sun/script/util/InterfaceImplementor.java Tue Jul 16 10:58:46 2013 +0100
++++ jdk/src/share/classes/com/sun/script/util/InterfaceImplementor.java Fri Oct 25 22:43:09 2013 +0100
+@@ -28,6 +28,7 @@
+ import javax.script.*;
+ import java.lang.reflect.*;
+ import java.security.*;
++import sun.reflect.misc.ReflectUtil;
+
+ /*
+ * java.lang.reflect.Proxy based interface implementor. This is meant
+@@ -82,8 +83,18 @@
+ if (iface == null || !iface.isInterface()) {
+ throw new IllegalArgumentException("interface Class expected");
+ }
++
++ if (System.getSecurityManager() != null &&
++ !Modifier.isPublic(iface.getModifiers())) {
++ throw new SecurityException("attempt to implement non-public interface");
++ }
++
++ // make sure restricted package interfaces are not attempted.
++ ReflectUtil.checkPackageAccess(iface.getName());
++
+ AccessControlContext accCtxt = AccessController.getContext();
+- return iface.cast(Proxy.newProxyInstance(iface.getClassLoader(),
++ return iface.cast(Proxy.newProxyInstance(
++ getLoaderForProxy(iface),
+ new Class[]{iface},
+ new InterfaceImplementorInvocationHandler(thiz, accCtxt)));
+ }
+@@ -101,4 +112,20 @@
+ // default is identity conversion
+ return args;
+ }
++
++ // get appropriate ClassLoader for generated Proxy class
++ private static ClassLoader getLoaderForProxy(Class<?> iface) {
++ ClassLoader loader = iface.getClassLoader();
++
++ // if bootstrap class, try TCCL
++ if (loader == null) {
++ loader = Thread.currentThread().getContextClassLoader();
++ }
++
++ // if TCCL is also null, try System class loader
++ if (loader == null) {
++ loader = ClassLoader.getSystemClassLoader();
++ }
++ return loader;
++ }
+ }
+diff -r 0b0490779c5b -r de490a43861e src/share/lib/security/java.security-linux
+--- jdk/src/share/lib/security/java.security-linux Tue Jul 16 10:58:46 2013 +0100
++++ jdk/src/share/lib/security/java.security-linux Fri Oct 25 22:43:09 2013 +0100
+@@ -133,6 +133,7 @@
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
+ com.sun.proxy.,\
++ com.sun.script.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+@@ -169,6 +170,7 @@
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
+ com.sun.proxy.,\
++ com.sun.script.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+diff -r 0b0490779c5b -r de490a43861e src/share/lib/security/java.security-solaris
+--- jdk/src/share/lib/security/java.security-solaris Tue Jul 16 10:58:46 2013 +0100
++++ jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:43:09 2013 +0100
+@@ -134,6 +134,7 @@
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
+ com.sun.proxy.,\
++ com.sun.script.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+@@ -171,6 +172,7 @@
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
+ com.sun.proxy.,\
++ com.sun.script.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+diff -r 0b0490779c5b -r de490a43861e src/share/lib/security/java.security-windows
+--- jdk/src/share/lib/security/java.security-windows Tue Jul 16 10:58:46 2013 +0100
++++ jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:43:09 2013 +0100
+@@ -134,6 +134,7 @@
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
+ com.sun.proxy.,\
++ com.sun.script.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+@@ -172,6 +173,7 @@
+ com.sun.istack.internal.,\
+ com.sun.jmx.,\
+ com.sun.proxy.,\
++ com.sun.script.,\
+ com.sun.org.apache.bcel.internal.,\
+ com.sun.org.apache.regexp.internal.,\
+ com.sun.org.apache.xerces.internal.,\
+diff -r 0b0490779c5b -r de490a43861e test/java/lang/SecurityManager/CheckPackageAccess.java
+--- jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Tue Jul 16 10:58:46 2013 +0100
++++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:43:09 2013 +0100
+@@ -74,6 +74,7 @@
+ "com.sun.org.apache.xml.internal.serializer.utils.",
+ "com.sun.org.apache.xml.internal.utils.",
+ "com.sun.org.glassfish.",
++ "com.sun.script.",
+ "oracle.jrockit.jfr.",
+ "org.jcp.xml.dsig.internal.",
+ };
diff --git a/java/openjdk6/files/icedtea/openjdk/8017505-better_client_service.patch b/java/openjdk6/files/icedtea/openjdk/8017505-better_client_service.patch
new file mode 100644
index 000000000000..1ab4a485ea76
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8017505-better_client_service.patch
@@ -0,0 +1,560 @@
+# HG changeset patch
+# User mkos
+# Date 1383022122 0
+# Tue Oct 29 04:48:42 2013 +0000
+# Node ID 4ea4a060f3748510aedf4355ae2dbf2921f15494
+# Parent 60ca74797572c7fb8682802738dda073e44aeea0
+8017505: Better Client Service
+Reviewed-by: mullan, ahgross, mgrebac
+
+diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/InstanceResolver.java
+--- jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/InstanceResolver.java Fri Oct 04 12:22:34 2013 -0400
++++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/InstanceResolver.java Tue Oct 29 04:48:42 2013 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2005, 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
+@@ -232,7 +232,7 @@
+ public Object invoke(Packet p, Method m, Object... args) throws InvocationTargetException, IllegalAccessException {
+ T t = resolve(p);
+ try {
+- return m.invoke(t, args );
++ return MethodUtil.invoke(t, m, args );
+ } finally {
+ postInvoke(p,t);
+ }
+diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/MethodUtil.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/api/server/MethodUtil.java Tue Oct 29 04:48:42 2013 +0000
+@@ -0,0 +1,109 @@
++/*
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
++ *
++ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
++ *
++ * The contents of this file are subject to the terms of either the GNU
++ * General Public License Version 2 only ("GPL") or the Common Development
++ * and Distribution License("CDDL") (collectively, the "License"). You
++ * may not use this file except in compliance with the License. You can
++ * obtain a copy of the License at
++ * http://glassfish.java.net/public/CDDL+GPL_1_1.html
++ * or packager/legal/LICENSE.txt. See the License for the specific
++ * language governing permissions and limitations under the License.
++ *
++ * When distributing the software, include this License Header Notice in each
++ * file and include the License file at packager/legal/LICENSE.txt.
++ *
++ * GPL Classpath Exception:
++ * Oracle designates this particular file as subject to the "Classpath"
++ * exception as provided by Oracle in the GPL Version 2 section of the License
++ * file that accompanied this code.
++ *
++ * Modifications:
++ * If applicable, add the following below the License Header, with the fields
++ * enclosed by brackets [] replaced by your own identifying information:
++ * "Portions Copyright [year] [name of copyright owner]"
++ *
++ * Contributor(s):
++ * If you wish your version of this file to be governed by only the CDDL or
++ * only the GPL Version 2, indicate your decision by adding "[Contributor]
++ * elects to include this software in this distribution under the [CDDL or GPL
++ * Version 2] license." If you don't indicate a single choice of license, a
++ * recipient has the option to distribute your version of this file under
++ * either the CDDL, the GPL Version 2 or to extend the choice of license to
++ * its licensees as provided above. However, if you add GPL Version 2 code
++ * and therefore, elected the GPL Version 2 license, then the option applies
++ * only if the new code is made subject to such option by the copyright
++ * holder.
++ */
++
++package com.sun.xml.internal.ws.api.server;
++
++import java.lang.reflect.InvocationTargetException;
++import java.lang.reflect.Method;
++import java.util.logging.Level;
++import java.util.logging.Logger;
++
++/**
++ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
++ * to java.lang,reflect.Method.invoke()
++ *
++ * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too!
++ */
++class MethodUtil {
++
++ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
++ private static final Method INVOKE_METHOD;
++
++ static {
++ Method method;
++ try {
++ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
++ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
++ }
++ } catch (Throwable t) {
++ method = null;
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
++ }
++ }
++ INVOKE_METHOD = method;
++ }
++
++ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
++ if (INVOKE_METHOD != null) {
++ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
++ }
++ try {
++ return INVOKE_METHOD.invoke(null, method, target, args);
++ } catch (InvocationTargetException ite) {
++ // unwrap invocation exception added by reflection code ...
++ throw unwrapException(ite);
++ }
++ } else {
++ // other then Oracle JDK ...
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
++ }
++ return method.invoke(target, args);
++ }
++ }
++
++ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
++ Throwable targetException = ite.getTargetException();
++ if (targetException != null && targetException instanceof InvocationTargetException) {
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
++ }
++ return (InvocationTargetException) targetException;
++ } else {
++ return ite;
++ }
++ }
++
++}
+diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/MethodUtil.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/MethodUtil.java Tue Oct 29 04:48:42 2013 +0000
+@@ -0,0 +1,109 @@
++/*
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
++ *
++ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
++ *
++ * The contents of this file are subject to the terms of either the GNU
++ * General Public License Version 2 only ("GPL") or the Common Development
++ * and Distribution License("CDDL") (collectively, the "License"). You
++ * may not use this file except in compliance with the License. You can
++ * obtain a copy of the License at
++ * http://glassfish.java.net/public/CDDL+GPL_1_1.html
++ * or packager/legal/LICENSE.txt. See the License for the specific
++ * language governing permissions and limitations under the License.
++ *
++ * When distributing the software, include this License Header Notice in each
++ * file and include the License file at packager/legal/LICENSE.txt.
++ *
++ * GPL Classpath Exception:
++ * Oracle designates this particular file as subject to the "Classpath"
++ * exception as provided by Oracle in the GPL Version 2 section of the License
++ * file that accompanied this code.
++ *
++ * Modifications:
++ * If applicable, add the following below the License Header, with the fields
++ * enclosed by brackets [] replaced by your own identifying information:
++ * "Portions Copyright [year] [name of copyright owner]"
++ *
++ * Contributor(s):
++ * If you wish your version of this file to be governed by only the CDDL or
++ * only the GPL Version 2, indicate your decision by adding "[Contributor]
++ * elects to include this software in this distribution under the [CDDL or GPL
++ * Version 2] license." If you don't indicate a single choice of license, a
++ * recipient has the option to distribute your version of this file under
++ * either the CDDL, the GPL Version 2 or to extend the choice of license to
++ * its licensees as provided above. However, if you add GPL Version 2 code
++ * and therefore, elected the GPL Version 2 license, then the option applies
++ * only if the new code is made subject to such option by the copyright
++ * holder.
++ */
++
++package com.sun.xml.internal.ws.client.sei;
++
++import java.lang.reflect.InvocationTargetException;
++import java.lang.reflect.Method;
++import java.util.logging.Level;
++import java.util.logging.Logger;
++
++/**
++ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
++ * to java.lang,reflect.Method.invoke()
++ * <p/>
++ * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too!
++ */
++class MethodUtil {
++
++ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
++ private static final Method INVOKE_METHOD;
++
++ static {
++ Method method;
++ try {
++ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
++ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
++ }
++ } catch (Throwable t) {
++ method = null;
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
++ }
++ }
++ INVOKE_METHOD = method;
++ }
++
++ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
++ if (INVOKE_METHOD != null) {
++ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
++ }
++ try {
++ return INVOKE_METHOD.invoke(null, method, target, args);
++ } catch (InvocationTargetException ite) {
++ // unwrap invocation exception added by reflection code ...
++ throw unwrapException(ite);
++ }
++ } else {
++ // other then Oracle JDK ...
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
++ }
++ return method.invoke(target, args);
++ }
++ }
++
++ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
++ Throwable targetException = ite.getTargetException();
++ if (targetException != null && targetException instanceof InvocationTargetException) {
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
++ }
++ return (InvocationTargetException) targetException;
++ } else {
++ return ite;
++ }
++ }
++
++}
+diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/SEIStub.java
+--- jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/SEIStub.java Fri Oct 04 12:22:34 2013 -0400
++++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/client/sei/SEIStub.java Tue Oct 29 04:48:42 2013 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2005, 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
+@@ -33,8 +33,8 @@
+ import com.sun.xml.internal.ws.api.message.Packet;
+ import com.sun.xml.internal.ws.api.model.MEP;
+ import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
++import com.sun.xml.internal.ws.api.pipe.Fiber;
+ import com.sun.xml.internal.ws.api.pipe.Tube;
+-import com.sun.xml.internal.ws.api.pipe.Fiber;
+ import com.sun.xml.internal.ws.binding.BindingImpl;
+ import com.sun.xml.internal.ws.client.RequestContext;
+ import com.sun.xml.internal.ws.client.ResponseContextReceiver;
+@@ -47,6 +47,8 @@
+ import java.lang.reflect.InvocationHandler;
+ import java.lang.reflect.InvocationTargetException;
+ import java.lang.reflect.Method;
++import java.lang.reflect.Modifier;
++import java.lang.reflect.Proxy;
+ import java.util.HashMap;
+ import java.util.Map;
+
+@@ -102,13 +104,14 @@
+ private final Map<Method, MethodHandler> methodHandlers = new HashMap<Method, MethodHandler>();
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
++ validateInputs(proxy, method);
+ MethodHandler handler = methodHandlers.get(method);
+ if (handler != null) {
+ return handler.invoke(proxy, args);
+ } else {
+ // we handle the other method invocations by ourselves
+ try {
+- return method.invoke(this, args);
++ return MethodUtil.invoke(this, method, args);
+ } catch (IllegalAccessException e) {
+ // impossible
+ throw new AssertionError(e);
+@@ -120,6 +123,17 @@
+ }
+ }
+
++ private void validateInputs(Object proxy, Method method) {
++ if (proxy == null || !Proxy.isProxyClass(proxy.getClass())) {
++ throw new IllegalStateException("Passed object is not proxy!");
++ }
++ Class<?> declaringClass = method.getDeclaringClass();
++ if (method == null || declaringClass == null
++ || Modifier.isStatic(method.getModifiers())) {
++ throw new IllegalStateException("Invoking static method is not allowed!");
++ }
++ }
++
+ public final Packet doProcess(Packet request, RequestContext rc, ResponseContextReceiver receiver) {
+ return super.process(request, rc, receiver);
+ }
+diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/policy/privateutil/MethodUtil.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/policy/privateutil/MethodUtil.java Tue Oct 29 04:48:42 2013 +0000
+@@ -0,0 +1,107 @@
++/*
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
++ *
++ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
++ *
++ * The contents of this file are subject to the terms of either the GNU
++ * General Public License Version 2 only ("GPL") or the Common Development
++ * and Distribution License("CDDL") (collectively, the "License"). You
++ * may not use this file except in compliance with the License. You can
++ * obtain a copy of the License at
++ * http://glassfish.java.net/public/CDDL+GPL_1_1.html
++ * or packager/legal/LICENSE.txt. See the License for the specific
++ * language governing permissions and limitations under the License.
++ *
++ * When distributing the software, include this License Header Notice in each
++ * file and include the License file at packager/legal/LICENSE.txt.
++ *
++ * GPL Classpath Exception:
++ * Oracle designates this particular file as subject to the "Classpath"
++ * exception as provided by Oracle in the GPL Version 2 section of the License
++ * file that accompanied this code.
++ *
++ * Modifications:
++ * If applicable, add the following below the License Header, with the fields
++ * enclosed by brackets [] replaced by your own identifying information:
++ * "Portions Copyright [year] [name of copyright owner]"
++ *
++ * Contributor(s):
++ * If you wish your version of this file to be governed by only the CDDL or
++ * only the GPL Version 2, indicate your decision by adding "[Contributor]
++ * elects to include this software in this distribution under the [CDDL or GPL
++ * Version 2] license." If you don't indicate a single choice of license, a
++ * recipient has the option to distribute your version of this file under
++ * either the CDDL, the GPL Version 2 or to extend the choice of license to
++ * its licensees as provided above. However, if you add GPL Version 2 code
++ * and therefore, elected the GPL Version 2 license, then the option applies
++ * only if the new code is made subject to such option by the copyright
++ * holder.
++ */
++
++package com.sun.xml.internal.ws.policy.privateutil;
++
++import java.lang.reflect.InvocationTargetException;
++import java.lang.reflect.Method;
++import java.util.logging.Level;
++import java.util.logging.Logger;
++
++/**
++ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
++ * to java.lang,reflect.Method.invoke()
++ */
++class MethodUtil {
++
++ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
++ private static final Method INVOKE_METHOD;
++
++ static {
++ Method method;
++ try {
++ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
++ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
++ }
++ } catch (Throwable t) {
++ method = null;
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
++ }
++ }
++ INVOKE_METHOD = method;
++ }
++
++ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
++ if (INVOKE_METHOD != null) {
++ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
++ }
++ try {
++ return INVOKE_METHOD.invoke(null, method, target, args);
++ } catch (InvocationTargetException ite) {
++ // unwrap invocation exception added by reflection code ...
++ throw unwrapException(ite);
++ }
++ } else {
++ // other then Oracle JDK ...
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
++ }
++ return method.invoke(target, args);
++ }
++ }
++
++ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
++ Throwable targetException = ite.getTargetException();
++ if (targetException != null && targetException instanceof InvocationTargetException) {
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
++ }
++ return (InvocationTargetException) targetException;
++ } else {
++ return ite;
++ }
++ }
++
++}
+diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/AbstractInstanceResolver.java
+--- jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/AbstractInstanceResolver.java Fri Oct 04 12:22:34 2013 -0400
++++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/AbstractInstanceResolver.java Tue Oct 29 04:48:42 2013 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2005, 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
+@@ -157,7 +157,7 @@
+ if (!method.isAccessible()) {
+ method.setAccessible(true);
+ }
+- method.invoke(instance,args);
++ MethodUtil.invoke(instance,method,args);
+ } catch (IllegalAccessException e) {
+ throw new ServerRtException("server.rt.err",e);
+ } catch (InvocationTargetException e) {
+diff -r 60ca74797572 -r 4ea4a060f374 drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/MethodUtil.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jaxws/drop_included/jaxws_src/src/com/sun/xml/internal/ws/server/MethodUtil.java Tue Oct 29 04:48:42 2013 +0000
+@@ -0,0 +1,109 @@
++/*
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
++ *
++ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
++ *
++ * The contents of this file are subject to the terms of either the GNU
++ * General Public License Version 2 only ("GPL") or the Common Development
++ * and Distribution License("CDDL") (collectively, the "License"). You
++ * may not use this file except in compliance with the License. You can
++ * obtain a copy of the License at
++ * http://glassfish.java.net/public/CDDL+GPL_1_1.html
++ * or packager/legal/LICENSE.txt. See the License for the specific
++ * language governing permissions and limitations under the License.
++ *
++ * When distributing the software, include this License Header Notice in each
++ * file and include the License file at packager/legal/LICENSE.txt.
++ *
++ * GPL Classpath Exception:
++ * Oracle designates this particular file as subject to the "Classpath"
++ * exception as provided by Oracle in the GPL Version 2 section of the License
++ * file that accompanied this code.
++ *
++ * Modifications:
++ * If applicable, add the following below the License Header, with the fields
++ * enclosed by brackets [] replaced by your own identifying information:
++ * "Portions Copyright [year] [name of copyright owner]"
++ *
++ * Contributor(s):
++ * If you wish your version of this file to be governed by only the CDDL or
++ * only the GPL Version 2, indicate your decision by adding "[Contributor]
++ * elects to include this software in this distribution under the [CDDL or GPL
++ * Version 2] license." If you don't indicate a single choice of license, a
++ * recipient has the option to distribute your version of this file under
++ * either the CDDL, the GPL Version 2 or to extend the choice of license to
++ * its licensees as provided above. However, if you add GPL Version 2 code
++ * and therefore, elected the GPL Version 2 license, then the option applies
++ * only if the new code is made subject to such option by the copyright
++ * holder.
++ */
++
++package com.sun.xml.internal.ws.server;
++
++import java.lang.reflect.InvocationTargetException;
++import java.lang.reflect.Method;
++import java.util.logging.Level;
++import java.util.logging.Logger;
++
++/**
++ * Utility class to invoke sun.reflect.misc.MethodUtil.invoke() if available. If not (other then Oracle JDK) fallbacks
++ * to java.lang,reflect.Method.invoke()
++ *
++ * Be careful, copy of this class exists in several packages, iny modification must be done to other copies too!
++ */
++class MethodUtil {
++
++ private static final Logger LOGGER = Logger.getLogger(MethodUtil.class.getName());
++ private static final Method INVOKE_METHOD;
++
++ static {
++ Method method;
++ try {
++ Class<?> clazz = Class.forName("sun.reflect.misc.MethodUtil");
++ method = clazz.getMethod("invoke", Method.class, Object.class, Object[].class);
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil found; it will be used to invoke methods.");
++ }
++ } catch (Throwable t) {
++ method = null;
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Class sun.reflect.misc.MethodUtil not found, probably non-Oracle JVM");
++ }
++ }
++ INVOKE_METHOD = method;
++ }
++
++ static Object invoke(Object target, Method method, Object[] args) throws IllegalAccessException, InvocationTargetException {
++ if (INVOKE_METHOD != null) {
++ // sun.reflect.misc.MethodUtil.invoke(method, owner, args)
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Invoking method using sun.reflect.misc.MethodUtil");
++ }
++ try {
++ return INVOKE_METHOD.invoke(null, method, target, args);
++ } catch (InvocationTargetException ite) {
++ // unwrap invocation exception added by reflection code ...
++ throw unwrapException(ite);
++ }
++ } else {
++ // other then Oracle JDK ...
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Invoking method directly, probably non-Oracle JVM");
++ }
++ return method.invoke(target, args);
++ }
++ }
++
++ private static InvocationTargetException unwrapException(InvocationTargetException ite) {
++ Throwable targetException = ite.getTargetException();
++ if (targetException != null && targetException instanceof InvocationTargetException) {
++ if (LOGGER.isLoggable(Level.FINE)) {
++ LOGGER.log(Level.FINE, "Unwrapping invocation target exception");
++ }
++ return (InvocationTargetException) targetException;
++ } else {
++ return ite;
++ }
++ }
++
++}
diff --git a/java/openjdk6/files/icedtea/openjdk/8017566-backout_part_of_8000450.patch b/java/openjdk6/files/icedtea/openjdk/8017566-backout_part_of_8000450.patch
new file mode 100644
index 000000000000..f66325cb8107
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8017566-backout_part_of_8000450.patch
@@ -0,0 +1,77 @@
+# HG changeset patch
+# User coffeys
+# Date 1373968726 -3600
+# Tue Jul 16 10:58:46 2013 +0100
+# Node ID 0b0490779c5b643b7a3e90ac6870c1ee4bd5a155
+# Parent 2a023db33371ce5ee42134cf0d860ab9f0adff92
+8017566: Backout 8000450 - Cannot access to com.sun.corba.se.impl.orb.ORBImpl
+Reviewed-by: mchung, chegar
+
+diff -r 2a023db33371 -r 0b0490779c5b src/share/lib/security/java.security-linux
+--- jdk/src/share/lib/security/java.security-linux Fri Oct 25 22:35:06 2013 +0100
++++ jdk/src/share/lib/security/java.security-linux Tue Jul 16 10:58:46 2013 +0100
+@@ -128,7 +128,6 @@
+ # corresponding RuntimePermission ("accessClassInPackage."+package) has
+ # been granted.
+ package.access=sun.,\
+- com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+@@ -165,7 +164,6 @@
+ # checkPackageDefinition.
+ #
+ package.definition=sun.,\
+- com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+diff -r 2a023db33371 -r 0b0490779c5b src/share/lib/security/java.security-solaris
+--- jdk/src/share/lib/security/java.security-solaris Fri Oct 25 22:35:06 2013 +0100
++++ jdk/src/share/lib/security/java.security-solaris Tue Jul 16 10:58:46 2013 +0100
+@@ -129,7 +129,6 @@
+ # corresponding RuntimePermission ("accessClassInPackage."+package) has
+ # been granted.
+ package.access=sun.,\
+- com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+@@ -167,7 +166,6 @@
+ # checkPackageDefinition.
+ #
+ package.definition=sun.,\
+- com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+diff -r 2a023db33371 -r 0b0490779c5b src/share/lib/security/java.security-windows
+--- jdk/src/share/lib/security/java.security-windows Fri Oct 25 22:35:06 2013 +0100
++++ jdk/src/share/lib/security/java.security-windows Tue Jul 16 10:58:46 2013 +0100
+@@ -129,7 +129,6 @@
+ # corresponding RuntimePermission ("accessClassInPackage."+package) has
+ # been granted.
+ package.access=sun.,\
+- com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+@@ -168,7 +167,6 @@
+ # checkPackageDefinition.
+ #
+ package.definition=sun.,\
+- com.sun.corba.se.impl.,\
+ com.sun.xml.internal.,\
+ com.sun.imageio.,\
+ com.sun.istack.internal.,\
+diff -r 2a023db33371 -r 0b0490779c5b test/java/lang/SecurityManager/CheckPackageAccess.java
+--- jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:35:06 2013 +0100
++++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Tue Jul 16 10:58:46 2013 +0100
+@@ -50,7 +50,6 @@
+ */
+ private static final String[] packages = {
+ "sun.",
+- "com.sun.corba.se.impl.",
+ "com.sun.xml.internal.",
+ "com.sun.imageio.",
+ "com.sun.istack.internal.",
diff --git a/java/openjdk6/files/icedtea/openjdk/8019292-better_attribute_value_exceptions.patch b/java/openjdk6/files/icedtea/openjdk/8019292-better_attribute_value_exceptions.patch
new file mode 100644
index 000000000000..12ffa0f1a6c9
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8019292-better_attribute_value_exceptions.patch
@@ -0,0 +1,57 @@
+# HG changeset patch
+# User sjiang
+# Date 1375797854 -7200
+# Tue Aug 06 16:04:14 2013 +0200
+# Node ID d80e6f4a4eec26137af6726cfb8abfe108ce23ea
+# Parent de490a43861e05f3da489db136687b1dc6f1949a
+8019292: Better Attribute Value Exceptions
+Reviewed-by: dfuchs, dholmes, ahgross
+
+diff -r de490a43861e -r d80e6f4a4eec src/share/classes/javax/management/BadAttributeValueExpException.java
+--- jdk/src/share/classes/javax/management/BadAttributeValueExpException.java Fri Oct 25 22:43:09 2013 +0100
++++ jdk/src/share/classes/javax/management/BadAttributeValueExpException.java Tue Aug 06 16:04:14 2013 +0200
+@@ -25,6 +25,9 @@
+
+ package javax.management;
+
++import java.io.IOException;
++import java.io.ObjectInputStream;
++
+
+ /**
+ * Thrown when an invalid MBean attribute is passed to a query
+@@ -51,7 +54,7 @@
+ * @param val the inappropriate value.
+ */
+ public BadAttributeValueExpException (Object val) {
+- this.val = val;
++ this.val = val == null ? null : val.toString();
+ }
+
+
+@@ -62,4 +65,25 @@
+ return "BadAttributeValueException: " + val;
+ }
+
++ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
++ ObjectInputStream.GetField gf = ois.readFields();
++ Object valObj = gf.get("val", null);
++
++ if (valObj == null) {
++ val = null;
++ } else if (valObj instanceof String) {
++ val= valObj;
++ } else if (System.getSecurityManager() == null
++ || valObj instanceof Long
++ || valObj instanceof Integer
++ || valObj instanceof Float
++ || valObj instanceof Double
++ || valObj instanceof Byte
++ || valObj instanceof Short
++ || valObj instanceof Boolean) {
++ val = valObj.toString();
++ } else { // the serialized object is from a version without JDK-8019292 fix
++ val = System.identityHashCode(valObj) + "@" + valObj.getClass().getName();
++ }
++ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8019584-invalid_notification_fix.patch b/java/openjdk6/files/icedtea/openjdk/8019584-invalid_notification_fix.patch
new file mode 100644
index 000000000000..bbbc168a683d
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8019584-invalid_notification_fix.patch
@@ -0,0 +1,69 @@
+# HG changeset patch
+# User jbachorik
+# Date 1374244166 -7200
+# Fri Jul 19 16:29:26 2013 +0200
+# Node ID 42cdf6988c2b81b322bf89778ddeb47265cd3bba
+# Parent a8132d72370c1f2467c9bb966d9355b387c35039
+8019584: javax/management/remote/mandatory/loading/MissingClassTest.java failed in nightly against jdk7u45: java.io.InvalidObjectException: Invalid notification: null
+Reviewed-by: mchung, sjiang, dfuchs, ahgross
+
+diff -r a8132d72370c -r 42cdf6988c2b src/share/classes/javax/management/remote/NotificationResult.java
+--- jdk/src/share/classes/javax/management/remote/NotificationResult.java Mon Jul 15 16:00:57 2013 +0100
++++ jdk/src/share/classes/javax/management/remote/NotificationResult.java Fri Jul 19 16:29:26 2013 +0200
+@@ -132,16 +132,17 @@
+ }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+- ObjectInputStream.GetField gf = ois.readFields();
+- TargetedNotification[] tNotifs = (TargetedNotification[])gf.get("targetedNotifications", null);
+- long snStart = gf.get("earliestSequenceNumber", -1L);
+- long snNext = gf.get("nextSequenceNumber", -1L);
++ ois.defaultReadObject();
+ try {
+- validate(tNotifs, snStart, snNext);
++ validate(
++ this.targetedNotifications,
++ this.earliestSequenceNumber,
++ this.nextSequenceNumber
++ );
+
+- this.targetedNotifications = tNotifs.length == 0 ? tNotifs : tNotifs.clone();
+- this.earliestSequenceNumber = snStart;
+- this.nextSequenceNumber = snNext;
++ this.targetedNotifications = this.targetedNotifications.length == 0 ?
++ this.targetedNotifications :
++ this.targetedNotifications.clone();
+ } catch (IllegalArgumentException e) {
+ throw new InvalidObjectException(e.getMessage());
+ }
+diff -r a8132d72370c -r 42cdf6988c2b src/share/classes/javax/management/remote/TargetedNotification.java
+--- jdk/src/share/classes/javax/management/remote/TargetedNotification.java Mon Jul 15 16:00:57 2013 +0100
++++ jdk/src/share/classes/javax/management/remote/TargetedNotification.java Fri Jul 19 16:29:26 2013 +0200
+@@ -132,13 +132,9 @@
+ // }
+
+ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
+- ObjectInputStream.GetField gf = ois.readFields();
+- Notification notification = (Notification)gf.get("notif", null);
+- Integer listenerId = (Integer)gf.get("id", null);
++ ois.defaultReadObject();
+ try {
+- validate(notification, listenerId);
+- this.notif = notification;
+- this.id = listenerId;
++ validate(this.notif, this.id);
+ } catch (IllegalArgumentException e) {
+ throw new InvalidObjectException(e.getMessage());
+ }
+diff -r a8132d72370c -r 42cdf6988c2b test/javax/management/remote/mandatory/loading/MissingClassTest.java
+--- jdk/test/javax/management/remote/mandatory/loading/MissingClassTest.java Mon Jul 15 16:00:57 2013 +0100
++++ jdk/test/javax/management/remote/mandatory/loading/MissingClassTest.java Fri Jul 19 16:29:26 2013 +0200
+@@ -23,7 +23,7 @@
+
+ /*
+ * @test
+- * @bug 4915825 4921009 4934965 4977469
++ * @bug 4915825 4921009 4934965 4977469 8019584
+ * @summary Tests behavior when client or server gets object of unknown class
+ * @author Eamonn McManus
+ * @run clean MissingClassTest SingleClassLoader
diff --git a/java/openjdk6/files/icedtea/openjdk/8019617-better_view_of_objects.patch b/java/openjdk6/files/icedtea/openjdk/8019617-better_view_of_objects.patch
new file mode 100644
index 000000000000..25a70c01539b
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8019617-better_view_of_objects.patch
@@ -0,0 +1,68 @@
+# HG changeset patch
+# User malenkov
+# Date 1373994034 -14400
+# Tue Jul 16 21:00:34 2013 +0400
+# Node ID 9cfb9105241489a5fbc3fcfdea15a6aee15b2cfc
+# Parent d80e6f4a4eec26137af6726cfb8abfe108ce23ea
+8019617: Better view of objects
+Reviewed-by: art, skoivu
+
+diff -r d80e6f4a4eec -r 9cfb91052414 src/share/classes/javax/swing/text/html/ObjectView.java
+--- jdk/src/share/classes/javax/swing/text/html/ObjectView.java Tue Aug 06 16:04:14 2013 +0200
++++ jdk/src/share/classes/javax/swing/text/html/ObjectView.java Tue Jul 16 21:00:34 2013 +0400
+@@ -31,6 +31,9 @@
+ import java.beans.*;
+ import java.lang.reflect.*;
+
++import sun.reflect.misc.MethodUtil;
++import sun.reflect.misc.ReflectUtil;
++
+ /**
+ * Component decorator that implements the view interface
+ * for &lt;object&gt; elements.
+@@ -87,6 +90,7 @@
+ AttributeSet attr = getElement().getAttributes();
+ String classname = (String) attr.getAttribute(HTML.Attribute.CLASSID);
+ try {
++ ReflectUtil.checkPackageAccess(classname);
+ Class c = Class.forName(classname, true,Thread.currentThread().
+ getContextClassLoader());
+ Object o = c.newInstance();
+@@ -116,28 +120,6 @@
+ }
+
+ /**
+- * Get a Class object to use for loading the
+- * classid. If possible, the Classloader
+- * used to load the associated Document is used.
+- * This would typically be the same as the ClassLoader
+- * used to load the EditorKit. If the documents
+- * ClassLoader is null,
+- * <code>Class.forName</code> is used.
+- */
+- private Class getClass(String classname) throws ClassNotFoundException {
+- Class klass;
+-
+- Class docClass = getDocument().getClass();
+- ClassLoader loader = docClass.getClassLoader();
+- if (loader != null) {
+- klass = loader.loadClass(classname);
+- } else {
+- klass = Class.forName(classname);
+- }
+- return klass;
+- }
+-
+- /**
+ * Initialize this component according the KEY/VALUEs passed in
+ * via the &lt;param&gt; elements in the corresponding
+ * &lt;object&gt; element.
+@@ -170,7 +152,7 @@
+ }
+ Object [] args = { value };
+ try {
+- writer.invoke(comp, args);
++ MethodUtil.invoke(writer, comp, args);
+ } catch (Exception ex) {
+ System.err.println("Invocation failed");
+ // invocation code
diff --git a/java/openjdk6/files/icedtea/openjdk/8019969-inet6_test_case_fix.patch b/java/openjdk6/files/icedtea/openjdk/8019969-inet6_test_case_fix.patch
new file mode 100644
index 000000000000..58299d057149
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8019969-inet6_test_case_fix.patch
@@ -0,0 +1,33 @@
+# HG changeset patch
+# User michaelm
+# Date 1373900457 -3600
+# Mon Jul 15 16:00:57 2013 +0100
+# Node ID a8132d72370c1f2467c9bb966d9355b387c35039
+# Parent bac5d0b011562017738501f02f7db4f39522a62e
+8019969: nioNetworkChannelInet6/SetOptionGetOptionTestInet6 test case crashes
+Reviewed-by: chegar
+
+diff -r bac5d0b01156 -r a8132d72370c src/windows/native/java/net/net_util_md.c
+--- jdk/src/windows/native/java/net/net_util_md.c Tue Oct 29 01:32:58 2013 +0000
++++ jdk/src/windows/native/java/net/net_util_md.c Mon Jul 15 16:00:57 2013 +0100
+@@ -879,7 +879,6 @@
+ family = (iafam == IPv4)? AF_INET : AF_INET6;
+ if (ipv6_available() && !(family == AF_INET && v4MappedAddress == JNI_FALSE)) {
+ struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
+- jbyteArray ipaddress;
+ jbyte caddr[16];
+ jint address, scopeid = 0;
+ jint cached_scope_id = 0;
+@@ -900,10 +899,9 @@
+ caddr[15] = (address & 0xff);
+ }
+ } else {
+- ipaddress = (*env)->GetObjectField(env, iaObj, ia6_ipaddressID);
+- scopeid = (jint)(*env)->GetIntField(env, iaObj, ia6_scopeidID);
++ getInet6Address_ipaddress(env, iaObj, (char *)caddr);
++ scopeid = getInet6Address_scopeid(env, iaObj);
+ cached_scope_id = (jint)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID);
+- (*env)->GetByteArrayRegion(env, ipaddress, 0, 16, caddr);
+ }
+
+ memset((char *)him6, 0, sizeof(struct SOCKADDR_IN6));
diff --git a/java/openjdk6/files/icedtea/openjdk/8019979-better_access_test.patch b/java/openjdk6/files/icedtea/openjdk/8019979-better_access_test.patch
new file mode 100644
index 000000000000..5a92a81b86c1
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8019979-better_access_test.patch
@@ -0,0 +1,154 @@
+# HG changeset patch
+# User coffeys
+# Date 1373625375 -3600
+# Fri Jul 12 11:36:15 2013 +0100
+# Node ID 3b6f55f02122398ba662fb581352c9c9b102c2e3
+# Parent f7a7c7d70e4968eb99e42f812c59900f545d7fa7
+8019979: Replace CheckPackageAccess test with better one from closed repo
+Reviewed-by: mullan, robilad
+
+diff -r f7a7c7d70e49 -r 3b6f55f02122 test/java/lang/SecurityManager/CheckPackageAccess.java
+--- jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Oct 25 22:18:57 2013 +0100
++++ jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Fri Jul 12 11:36:15 2013 +0100
+@@ -22,31 +22,128 @@
+ */
+
+ /*
+- * @test
+- * @bug 7146431 8000450
+- * @summary Test that internal packages cannot be accessed
++ * @test
++ * @bug 6741606 7146431 8000450
++ * @summary Make sure all restricted packages listed in the package.access
++ * property in the java.security file are blocked
++ * @run main/othervm CheckPackageAccess
+ */
+
++import java.security.Security;
++import java.util.Collections;
++import java.util.Arrays;
++import java.util.ArrayList;
++import java.util.List;
++import java.util.StringTokenizer;
++
++/*
++ * The main benefit of this test is to catch merge errors or other types
++ * of issues where one or more of the packages are accidentally
++ * removed. This is why the packages that are known to be restricted have to
++ * be explicitly listed below.
++ */
+ public class CheckPackageAccess {
+
++ /*
++ * This array should be updated whenever new packages are added to the
++ * package.access property in the java.security file
++ */
++ private static final String[] packages = {
++ "sun.",
++ "com.sun.corba.se.impl.",
++ "com.sun.xml.internal.",
++ "com.sun.imageio.",
++ "com.sun.istack.internal.",
++ "com.sun.jmx.",
++ "com.sun.proxy.",
++ "com.sun.org.apache.bcel.internal.",
++ "com.sun.org.apache.regexp.internal.",
++ "com.sun.org.apache.xerces.internal.",
++ "com.sun.org.apache.xpath.internal.",
++ "com.sun.org.apache.xalan.internal.extensions.",
++ "com.sun.org.apache.xalan.internal.lib.",
++ "com.sun.org.apache.xalan.internal.res.",
++ "com.sun.org.apache.xalan.internal.templates.",
++ "com.sun.org.apache.xalan.internal.utils.",
++ "com.sun.org.apache.xalan.internal.xslt.",
++ "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
++ "com.sun.org.apache.xalan.internal.xsltc.compiler.",
++ "com.sun.org.apache.xalan.internal.xsltc.trax.",
++ "com.sun.org.apache.xalan.internal.xsltc.util.",
++ "com.sun.org.apache.xml.internal.res.",
++ "com.sun.org.apache.xml.internal.security.",
++ "com.sun.org.apache.xml.internal.serializer.utils.",
++ "com.sun.org.apache.xml.internal.utils.",
++ "com.sun.org.glassfish.",
++ "oracle.jrockit.jfr.",
++ "org.jcp.xml.dsig.internal.",
++ };
++
+ public static void main(String[] args) throws Exception {
++ List<String> pkgs = new ArrayList<>(Arrays.asList(packages));
++ String osName = System.getProperty("os.name");
++ if (osName.contains("OS X")) {
++ pkgs.add("apple."); // add apple package for OS X
++ } else if (osName.startsWith("Windows")) {
++ pkgs.add("com.sun.java.accessibility.");
++ }
+
+- String[] pkgs = new String[] {
+- "com.sun.corba.se.impl.",
+- "com.sun.org.apache.xerces.internal.utils.",
+- "com.sun.org.apache.xalan.internal.utils." };
+- SecurityManager sm = new SecurityManager();
+- System.setSecurityManager(sm);
+- for (String pkg : pkgs) {
+- System.out.println("Checking package access for " + pkg);
++ List<String> jspkgs =
++ getPackages(Security.getProperty("package.access"));
++
++ // Sort to ensure lists are comparable
++ Collections.sort(pkgs);
++ Collections.sort(jspkgs);
++
++ if (!pkgs.equals(jspkgs)) {
++ for (String p : pkgs)
++ if (!jspkgs.contains(p))
++ System.out.println("In golden set, but not in j.s file: " + p);
++ for (String p : jspkgs)
++ if (!pkgs.contains(p))
++ System.out.println("In j.s file, but not in golden set: " + p);
++
++
++ throw new RuntimeException("restricted packages are not " +
++ "consistent with java.security file");
++ }
++ System.setSecurityManager(new SecurityManager());
++ SecurityManager sm = System.getSecurityManager();
++ for (String pkg : packages) {
++ String subpkg = pkg + "foo";
+ try {
+ sm.checkPackageAccess(pkg);
+- throw new Exception("Expected PackageAccess SecurityException not thrown");
++ throw new RuntimeException("Able to access " + pkg +
++ " package");
++ } catch (SecurityException se) { }
++ try {
++ sm.checkPackageAccess(subpkg);
++ throw new RuntimeException("Able to access " + subpkg +
++ " package");
+ } catch (SecurityException se) { }
+ try {
+ sm.checkPackageDefinition(pkg);
+- throw new Exception("Expected PackageDefinition SecurityException not thrown");
++ throw new RuntimeException("Able to define class in " + pkg +
++ " package");
++ } catch (SecurityException se) { }
++ try {
++ sm.checkPackageDefinition(subpkg);
++ throw new RuntimeException("Able to define class in " + subpkg +
++ " package");
+ } catch (SecurityException se) { }
+ }
++ System.out.println("Test passed");
++ }
++
++ private static List<String> getPackages(String p) {
++ List<String> packages = new ArrayList<>();
++ if (p != null && !p.equals("")) {
++ StringTokenizer tok = new StringTokenizer(p, ",");
++ while (tok.hasMoreElements()) {
++ String s = tok.nextToken().trim();
++ packages.add(s);
++ }
++ }
++ return packages;
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8020293-jvm_crash.patch b/java/openjdk6/files/icedtea/openjdk/8020293-jvm_crash.patch
new file mode 100644
index 000000000000..920bce81adbe
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8020293-jvm_crash.patch
@@ -0,0 +1,40 @@
+# HG changeset patch
+# User jchen
+# Date 1374527199 25200
+# Mon Jul 22 14:06:39 2013 -0700
+# Node ID 2adb9f71f6c0723acf40877f059d276557b71034
+# Parent 150e0c3e95ce6869f8e7b42c6d8683817433e124
+8020293: JVM crash
+Reviewed-by: prr, jgodinez
+
+diff -r 150e0c3e95ce -r 2adb9f71f6c0 src/share/classes/sun/font/GlyphLayout.java
+--- jdk/src/share/classes/sun/font/GlyphLayout.java Mon Oct 28 20:56:09 2013 +0000
++++ jdk/src/share/classes/sun/font/GlyphLayout.java Mon Jul 22 14:06:39 2013 -0700
+@@ -468,9 +468,10 @@
+ _gvdata.grow();
+ }
+ }
+- if (_gvdata._count < 0) {
+- break;
+- }
++ }
++ // Break out of the outer for loop if layout fails.
++ if (_gvdata._count < 0) {
++ break;
+ }
+ }
+
+diff -r 150e0c3e95ce -r 2adb9f71f6c0 src/share/native/sun/font/layout/SunLayoutEngine.cpp
+--- jdk/src/share/native/sun/font/layout/SunLayoutEngine.cpp Mon Oct 28 20:56:09 2013 +0000
++++ jdk/src/share/native/sun/font/layout/SunLayoutEngine.cpp Mon Jul 22 14:06:39 2013 -0700
+@@ -104,6 +104,10 @@
+
+ int putGV(JNIEnv* env, jint gmask, jint baseIndex, jobject gvdata, const LayoutEngine* engine, int glyphCount) {
+ int count = env->GetIntField(gvdata, gvdCountFID);
++ if (count < 0) {
++ JNU_ThrowInternalError(env, "count negative");
++ return 0;
++ }
+
+ jarray glyphArray = (jarray)env->GetObjectField(gvdata, gvdGlyphsFID);
+ if (IS_NULL(glyphArray)) {
diff --git a/java/openjdk6/files/icedtea/openjdk/8020943-memory_leak.patch b/java/openjdk6/files/icedtea/openjdk/8020943-memory_leak.patch
new file mode 100644
index 000000000000..92967c051909
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8020943-memory_leak.patch
@@ -0,0 +1,32 @@
+# HG changeset patch
+# User kevinw
+# Date 1375442806 -3600
+# Fri Aug 02 12:26:46 2013 +0100
+# Node ID 2660219948088d89dd3fc285e093dab2520349e5
+# Parent 4b3487aa553cca3fb7ecb74d284b9524d0bf5bf8
+8020943: Memory leak when GCNotifier uses create_from_platform_dependent_str()
+Reviewed-by: mgerdin, fparain, dcubed
+
+diff -r 4b3487aa553c -r 266021994808 src/share/vm/services/gcNotifier.cpp
+--- hotspot/src/share/vm/services/gcNotifier.cpp Thu Oct 17 19:28:00 2013 +0100
++++ hotspot/src/share/vm/services/gcNotifier.cpp Fri Aug 02 12:26:46 2013 +0100
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+@@ -211,9 +211,9 @@
+ NotificationMark nm(request);
+ Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD);
+
+- Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
+- Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
+- Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
++ Handle objName = java_lang_String::create_from_str(request->gcManager->name(), CHECK);
++ Handle objAction = java_lang_String::create_from_str(request->gcAction, CHECK);
++ Handle objCause = java_lang_String::create_from_str(request->gcCause, CHECK);
+
+ klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
+ instanceKlassHandle gc_mbean_klass(THREAD, k);
diff --git a/java/openjdk6/files/icedtea/openjdk/8021290-signature_validation.patch b/java/openjdk6/files/icedtea/openjdk/8021290-signature_validation.patch
new file mode 100644
index 000000000000..1cb588fecc68
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8021290-signature_validation.patch
@@ -0,0 +1,55 @@
+# HG changeset patch
+# User mullan
+# Date 1375219222 14400
+# Tue Jul 30 17:20:22 2013 -0400
+# Node ID 3e758b40337ef9da5ad030d0ac60ab4407357277
+# Parent 5e3c766d18092d498d9019827c1058a32f1c4e2a
+8021290: Better signature validation
+Reviewed-by: xuelei, ahgross
+
+diff -r 5e3c766d1809 -r 3e758b40337e src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
+--- jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Fri Oct 15 10:55:59 2010 -0400
++++ jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java Tue Jul 30 17:20:22 2013 -0400
+@@ -44,6 +44,9 @@
+ }
+
+ public void write(byte[] arg0) {
++ if ((Integer.MAX_VALUE - pos) < arg0.length) {
++ throw new OutOfMemoryError();
++ }
+ int newPos = pos + arg0.length;
+ if (newPos > size) {
+ expandSize(newPos);
+@@ -53,6 +56,9 @@
+ }
+
+ public void write(byte[] arg0, int arg1, int arg2) {
++ if ((Integer.MAX_VALUE - pos) < arg2) {
++ throw new OutOfMemoryError();
++ }
+ int newPos = pos + arg2;
+ if (newPos > size) {
+ expandSize(newPos);
+@@ -62,6 +68,9 @@
+ }
+
+ public void write(int arg0) {
++ if ((Integer.MAX_VALUE - pos) == 0) {
++ throw new OutOfMemoryError();
++ }
+ int newPos = pos + 1;
+ if (newPos > size) {
+ expandSize(newPos);
+@@ -82,7 +91,11 @@
+ private void expandSize(int newPos) {
+ int newSize = size;
+ while (newPos > newSize) {
+- newSize = newSize<<2;
++ newSize = newSize << 1;
++ // Deal with overflow
++ if (newSize < 0) {
++ newSize = Integer.MAX_VALUE;
++ }
+ }
+ byte newBuf[] = new byte[newSize];
+ System.arraycopy(buf, 0, newBuf, 0, pos);
diff --git a/java/openjdk6/files/icedtea/openjdk/8021355-splashscreen_regression.patch b/java/openjdk6/files/icedtea/openjdk/8021355-splashscreen_regression.patch
new file mode 100644
index 000000000000..c5c8d4a08aa2
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8021355-splashscreen_regression.patch
@@ -0,0 +1,53 @@
+# HG changeset patch
+# User ksrini
+# Date 1383014349 0
+# Tue Oct 29 02:39:09 2013 +0000
+# Node ID a5d00a180798f25254bf6f15b7dc31a0d5df60c2
+# Parent 5896fe42b0a429fb5be7abee630b98fa2ec00df3
+8021355: REGRESSION: Five closed/java/awt/SplashScreen tests fail since 7u45 b01 on Linux, Solaris
+Reviewed-by: dholmes, anthony, ahgross, erikj, omajid
+
+diff -r 5896fe42b0a4 -r a5d00a180798 src/solaris/bin/java_md.c
+--- jdk/src/solaris/bin/java_md.c Wed Aug 07 16:51:59 2013 +0400
++++ jdk/src/solaris/bin/java_md.c Tue Oct 29 02:39:09 2013 +0000
+@@ -46,6 +46,10 @@
+ #define JVM_DLL "libjvm.so"
+ #define JAVA_DLL "libjava.so"
+
++#define JRE_ERROR1 "Error: Could not find Java SE Runtime Environment."
++#define JRE_ERROR11 "Error: Path length exceeds maximum length (PATH_MAX)"
++#define JRE_ERROR13 "Error: String processing operation failed"
++
+ /*
+ * If a processor / os combination has the ability to run binaries of
+ * two data models and cohabitation of jre/jdk bits with both data
+@@ -1700,7 +1704,28 @@
+
+ void* SplashProcAddress(const char* name) {
+ if (!hSplashLib) {
+- hSplashLib = dlopen(SPLASHSCREEN_SO, RTLD_LAZY | RTLD_GLOBAL);
++ int ret;
++ char jrePath[MAXPATHLEN];
++ char splashPath[MAXPATHLEN];
++
++ if (!GetJREPath(jrePath, sizeof(jrePath), GetArch(), JNI_FALSE)) {
++ ReportErrorMessage(JRE_ERROR1, JNI_TRUE);
++ return NULL;
++ }
++ ret = snprintf(splashPath, sizeof(splashPath), "%s/lib/%s/%s",
++ jrePath, GetArch(), SPLASHSCREEN_SO);
++
++ if (ret >= (int) sizeof(splashPath)) {
++ ReportErrorMessage(JRE_ERROR11, JNI_TRUE);
++ return NULL;
++ }
++ if (ret < 0) {
++ ReportErrorMessage(JRE_ERROR13, JNI_TRUE);
++ return NULL;
++ }
++ hSplashLib = dlopen(splashPath, RTLD_LAZY | RTLD_GLOBAL);
++ if (_launcher_debug)
++ printf("Info: loaded %s\n", splashPath);
+ }
+ if (hSplashLib) {
+ void* sym = dlsym(hSplashLib, name);
diff --git a/java/openjdk6/files/icedtea/openjdk/8021366-jaxp_test_fix-01.patch b/java/openjdk6/files/icedtea/openjdk/8021366-jaxp_test_fix-01.patch
new file mode 100644
index 000000000000..04aea00a5df4
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8021366-jaxp_test_fix-01.patch
@@ -0,0 +1,21 @@
+# HG changeset patch
+# User joehw
+# Date 1375178534 25200
+# Tue Jul 30 03:02:14 2013 -0700
+# Node ID 674ada27a93f4ecd359617d5a27cb2dfe52c44b4
+# Parent 0927621944ccb163d7dcdea7b94b10dfab58f5f1
+8021366: java_util/Properties/PropertiesWithOtherEncodings fails during 7u45 nightly testing
+Reviewed-by: lancea, alanb, dfuchs, mullan
+
+diff -r 0927621944cc -r 674ada27a93f drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Tue Oct 29 08:01:29 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/xml/internal/stream/Entity.java Tue Jul 30 03:02:14 2013 -0700
+@@ -248,7 +248,7 @@
+ public int fBufferSize = DEFAULT_BUFFER_SIZE;
+
+ /** Default buffer size before we've finished with the XMLDecl: */
+- public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 64;
++ public static final int DEFAULT_XMLDECL_BUFFER_SIZE = 28;
+
+ /** Default internal entity buffer size (1024). */
+ public static final int DEFAULT_INTERNAL_BUFFER_SIZE = 1024;
diff --git a/java/openjdk6/files/icedtea/openjdk/8021577-bean_serialization_fix.patch b/java/openjdk6/files/icedtea/openjdk/8021577-bean_serialization_fix.patch
new file mode 100644
index 000000000000..396abf4e10ea
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8021577-bean_serialization_fix.patch
@@ -0,0 +1,25 @@
+# HG changeset patch
+# User jbachorik
+# Date 1375098221 25200
+# Mon Jul 29 04:43:41 2013 -0700
+# Node ID 21358b9e406319f4d9ddfd663572dd71a093ce08
+# Parent 42cdf6988c2b81b322bf89778ddeb47265cd3bba
+8021577: JCK test api/javax_management/jmx_serial/modelmbean/ModelMBeanNotificationInfo/serial/index.html#Input has failed since jdk 7u45 b01
+Reviewed-by: alanb, dfuchs, ahgross
+
+diff -r 42cdf6988c2b -r 21358b9e4063 src/share/classes/javax/management/MBeanNotificationInfo.java
+--- jdk/src/share/classes/javax/management/MBeanNotificationInfo.java Fri Jul 19 16:29:26 2013 +0200
++++ jdk/src/share/classes/javax/management/MBeanNotificationInfo.java Mon Jul 29 04:43:41 2013 -0700
+@@ -210,11 +210,6 @@
+ ObjectInputStream.GetField gf = ois.readFields();
+ String[] t = (String[])gf.get("types", null);
+
+- if (t == null) {
+- throw new InvalidObjectException("Trying to deserialize an invalid " +
+- "instance of " + MBeanNotificationInfo.class +
+- "[types=null]");
+- }
+- types = t.length == 0 ? t : t.clone();
++ types = (t != null && t.length != 0) ? t.clone() : NO_TYPES;
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8021933-jaxp_test_fix-02.patch b/java/openjdk6/files/icedtea/openjdk/8021933-jaxp_test_fix-02.patch
new file mode 100644
index 000000000000..f3ad91a9b147
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8021933-jaxp_test_fix-02.patch
@@ -0,0 +1,33 @@
+# HG changeset patch
+# User joehw
+# Date 1375252858 25200
+# Tue Jul 30 23:40:58 2013 -0700
+# Node ID dce0c261a1837e664e4d8739b97e8758a1fa0de2
+# Parent 674ada27a93f4ecd359617d5a27cb2dfe52c44b4
+8021933: Add extra check for fix # JDK-8014530
+Reviewed-by: alanb, lancea
+
+diff -r 674ada27a93f -r dce0c261a183 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Tue Jul 30 03:02:14 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java Tue Jul 30 23:40:58 2013 -0700
+@@ -1237,7 +1237,7 @@
+ //Revisit :: IMO this is not right place to check
+ // maxOccurNodeLimit.
+ int maxOccurNodeLimit = fSchemaHandler.fSecureProcessing.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT);
+- if (max > maxOccurNodeLimit) {
++ if (max > maxOccurNodeLimit && !fSchemaHandler.fSecureProcessing.isNoLimit(maxOccurNodeLimit)) {
+ reportSchemaFatalError("maxOccurLimit", new Object[] {new Integer(maxOccurNodeLimit)}, element);
+
+ // reset max values in case processing continues on error
+diff -r 674ada27a93f -r dce0c261a183 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Jul 30 03:02:14 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Jul 30 23:40:58 2013 -0700
+@@ -257,7 +257,7 @@
+ "FeatureNameNull", null));
+ }
+ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+- return (fSecurityManager != null);
++ return (fSecurityManager !=null && fSecurityManager.isSecureProcessing());
+ }
+ try {
+ return fXMLSchemaLoader.getFeature(name);
diff --git a/java/openjdk6/files/icedtea/openjdk/8021969-jnlp_load_failure.patch b/java/openjdk6/files/icedtea/openjdk/8021969-jnlp_load_failure.patch
new file mode 100644
index 000000000000..2e12b577eeaa
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8021969-jnlp_load_failure.patch
@@ -0,0 +1,25 @@
+# HG changeset patch
+# User malenkov
+# Date 1375879919 -14400
+# Wed Aug 07 16:51:59 2013 +0400
+# Node ID 5896fe42b0a429fb5be7abee630b98fa2ec00df3
+# Parent 21358b9e406319f4d9ddfd663572dd71a093ce08
+8021969: The index_AccessAllowed jnlp can not load successfully with exception thrown in the log.
+Reviewed-by: art, skoivu
+
+diff -r 21358b9e4063 -r 5896fe42b0a4 src/share/classes/java/awt/datatransfer/DataFlavor.java
+--- jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Mon Jul 29 04:43:41 2013 -0700
++++ jdk/src/share/classes/java/awt/datatransfer/DataFlavor.java Wed Aug 07 16:51:59 2013 +0400
+@@ -145,11 +145,7 @@
+ } catch (SecurityException exception) {
+ // ignore secured class loaders
+ }
+- if (fallback != null) {
+- return Class.forName(className, true, fallback);
+- } else {
+- throw new ClassNotFoundException(className);
+- }
++ return Class.forName(className, true, fallback);
+ }
+
+ /*
diff --git a/java/openjdk6/files/icedtea/openjdk/8022661-writeobject_flush.patch b/java/openjdk6/files/icedtea/openjdk/8022661-writeobject_flush.patch
new file mode 100644
index 000000000000..a13b8c5161b3
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8022661-writeobject_flush.patch
@@ -0,0 +1,20 @@
+# HG changeset patch
+# User chegar
+# Date 1376052613 -3600
+# Fri Aug 09 13:50:13 2013 +0100
+# Node ID 6c0b775b1ff2a0a0ba0fe797cfe18c511f9ee3c1
+# Parent a5d00a180798f25254bf6f15b7dc31a0d5df60c2
+8022661: InetAddress.writeObject() performs flush() on object output stream
+Reviewed-by: michaelm, alanb
+
+diff -r a5d00a180798 -r 6c0b775b1ff2 src/share/classes/java/net/InetAddress.java
+--- jdk/src/share/classes/java/net/InetAddress.java Tue Oct 29 02:39:09 2013 +0000
++++ jdk/src/share/classes/java/net/InetAddress.java Fri Aug 09 13:50:13 2013 +0100
+@@ -1586,7 +1586,6 @@
+ pf.put("address", holder().address);
+ pf.put("family", holder().family);
+ s.writeFields();
+- s.flush();
+ }
+ }
+
diff --git a/java/openjdk6/files/icedtea/openjdk/8022682-supporting_xom.patch b/java/openjdk6/files/icedtea/openjdk/8022682-supporting_xom.patch
new file mode 100644
index 000000000000..c72d12ce5762
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8022682-supporting_xom.patch
@@ -0,0 +1,250 @@
+# HG changeset patch
+# User joehw
+# Date 1383034215 0
+# Tue Oct 29 08:10:15 2013 +0000
+# Node ID 20ffb814205c67b5ded678ee6c69b2aa0d6cebb1
+# Parent dce0c261a1837e664e4d8739b97e8758a1fa0de2
+8022682: Supporting XOM
+Reviewed-by: alanb, chegar, lancea
+
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Oct 29 08:10:15 2013 +0000
+@@ -168,6 +168,17 @@
+ //add internal stax property
+ supportedProps.put( Constants.XERCES_PROPERTY_PREFIX + Constants.STAX_ENTITY_RESOLVER_PROPERTY , new StaxEntityResolverWrapper((XMLResolver)value)) ;
+ }
++
++ /**
++ * It's possible for users to set a security manager through the interface.
++ * If it's the old SecurityManager, convert it to the new XMLSecurityManager
++ */
++ if (property.equals(Constants.SECURITY_MANAGER)) {
++ fSecurityManager = XMLSecurityManager.convert(value, fSecurityManager);
++ supportedProps.put(Constants.SECURITY_MANAGER, fSecurityManager);
++ return;
++ }
++
+ supportedProps.put(property, value ) ;
+ if(equivalentProperty != null){
+ supportedProps.put(equivalentProperty, value ) ;
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 08:10:15 2013 +0000
+@@ -352,7 +352,7 @@
+ "ProperyNameNull", null));
+ }
+ if (name.equals(SECURITY_MANAGER)) {
+- fSecurityManager = (XMLSecurityManager) object;
++ fSecurityManager = XMLSecurityManager.convert(object, fSecurityManager);
+ fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
+ return;
+ }
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java Tue Oct 29 08:10:15 2013 +0000
+@@ -28,6 +28,7 @@
+ import com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper;
+ import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter;
+ import com.sun.org.apache.xerces.internal.util.SymbolTable;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.XNIException;
+ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
+@@ -528,7 +529,30 @@
+ */
+ public void setProperty(String propertyId, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
++ /**
++ * It's possible for users to set a security manager through the interface.
++ * If it's the old SecurityManager, convert it to the new XMLSecurityManager
++ */
++ if (propertyId.equals(Constants.SECURITY_MANAGER)) {
++ securityManager = XMLSecurityManager.convert(value, securityManager);
++ setProperty0(Constants.SECURITY_MANAGER, securityManager);
++ return;
++ }
+
++ if (securityManager == null) {
++ securityManager = new XMLSecurityManager(true);
++ setProperty0(Constants.SECURITY_MANAGER, securityManager);
++ }
++
++ //check if the property is managed by security manager
++ if (!securityManager.setLimit(propertyId, XMLSecurityManager.State.APIPROPERTY, value)) {
++ //fall back to the default configuration to handle the property
++ setProperty0(propertyId, value);
++ }
++ }
++
++ public void setProperty0(String propertyId, Object value)
++ throws SAXNotRecognizedException, SAXNotSupportedException {
+ try {
+ fConfiguration.setProperty(propertyId, value);
+ }
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java Tue Oct 29 08:10:15 2013 +0000
+@@ -181,6 +181,9 @@
+ protected static final String LOCALE =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
+
++ /** Property identifier: Security manager. */
++ private static final String SECURITY_MANAGER = Constants.SECURITY_MANAGER;
++
+ // debugging
+
+ /** Set to true and recompile to print exception stack trace. */
+@@ -325,7 +328,8 @@
+ VALIDATION_MANAGER,
+ JAXP_SCHEMA_SOURCE,
+ JAXP_SCHEMA_LANGUAGE,
+- LOCALE
++ LOCALE,
++ SECURITY_MANAGER
+ };
+ addRecognizedProperties(recognizedProperties);
+
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java Tue Oct 29 08:10:15 2013 +0000
+@@ -154,6 +154,9 @@
+ protected static final String LOCALE =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY;
+
++ /** Property identifier: Security manager. */
++ private static final String SECURITY_MANAGER = Constants.SECURITY_MANAGER;
++
+ // debugging
+
+ /** Set to true and recompile to print exception stack trace. */
+@@ -307,7 +310,8 @@
+ XMLGRAMMAR_POOL,
+ DATATYPE_VALIDATOR_FACTORY,
+ VALIDATION_MANAGER,
+- LOCALE
++ LOCALE,
++ SECURITY_MANAGER
+ };
+ addRecognizedProperties(recognizedProperties);
+
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Oct 29 08:10:15 2013 +0000
+@@ -74,7 +74,7 @@
+ XMLGRAMMAR_POOL,
+ };
+
+- XMLSecurityManager securityManager;
++
+ //
+ // Constructors
+ //
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java Tue Oct 29 08:10:15 2013 +0000
+@@ -563,8 +563,6 @@
+
+ fVersionDetector = new XMLVersionDetector();
+
+- fProperties.put(SECURITY_MANAGER, new XMLSecurityManager(true));
+-
+ // add message formatters
+ if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
+ XMLMessageFormatter xmft = new XMLMessageFormatter();
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java Tue Oct 29 08:10:15 2013 +0000
+@@ -23,6 +23,7 @@
+ import java.io.IOException;
+
+ import com.sun.org.apache.xerces.internal.impl.Constants;
++import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.XNIException;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
+@@ -78,6 +79,10 @@
+ /** The parser configuration. */
+ protected XMLParserConfiguration fConfiguration;
+
++ /** The XML Security Manager. */
++ XMLSecurityManager securityManager;
++
++
+ //
+ // Constructors
+ //
+@@ -118,6 +123,11 @@
+ */
+ public void parse(XMLInputSource inputSource)
+ throws XNIException, IOException {
++ // null indicates that the parser is called directly, initialize them
++ if (securityManager == null) {
++ securityManager = new XMLSecurityManager(true);
++ fConfiguration.setProperty(Constants.SECURITY_MANAGER, securityManager);
++ }
+
+ reset();
+ fConfiguration.parse(inputSource);
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLLimitAnalyzer.java Tue Oct 29 08:10:15 2013 +0000
+@@ -203,6 +203,9 @@
+ }
+
+ public boolean isTracking(String name) {
++ if (entityStart == null) {
++ return false;
++ }
+ return entityStart.equals(name);
+ }
+ /**
+diff -r dce0c261a183 -r 20ffb814205c drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Tue Jul 30 23:40:58 2013 -0700
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/utils/XMLSecurityManager.java Tue Oct 29 08:10:15 2013 +0000
+@@ -26,6 +26,7 @@
+ package com.sun.org.apache.xerces.internal.utils;
+
+ import com.sun.org.apache.xerces.internal.impl.Constants;
++import com.sun.org.apache.xerces.internal.util.SecurityManager;
+
+ /**
+ * This class manages standard and implementation-specific limitations.
+@@ -518,4 +519,37 @@
+ }
+ return false;
+ }
++
++
++ /**
++ * Convert a value set through setProperty to XMLSecurityManager.
++ * If the value is an instance of XMLSecurityManager, use it to override the default;
++ * If the value is an old SecurityManager, convert to the new XMLSecurityManager.
++ *
++ * @param value user specified security manager
++ * @param securityManager an instance of XMLSecurityManager
++ * @return an instance of the new security manager XMLSecurityManager
++ */
++ static public XMLSecurityManager convert(Object value, XMLSecurityManager securityManager) {
++ if (value == null) {
++ if (securityManager == null) {
++ securityManager = new XMLSecurityManager(true);
++ }
++ return securityManager;
++ }
++ if (XMLSecurityManager.class.isAssignableFrom(value.getClass())) {
++ return (XMLSecurityManager)value;
++ } else {
++ if (securityManager == null) {
++ securityManager = new XMLSecurityManager(true);
++ }
++ if (SecurityManager.class.isAssignableFrom(value.getClass())) {
++ SecurityManager origSM = (SecurityManager)value;
++ securityManager.setLimit(Limit.MAX_OCCUR_NODE_LIMIT, State.APIPROPERTY, origSM.getMaxOccurNodeLimit());
++ securityManager.setLimit(Limit.ENTITY_EXPANSION_LIMIT, State.APIPROPERTY, origSM.getEntityExpansionLimit());
++ securityManager.setLimit(Limit.ELEMENT_ATTRIBUTE_LIMIT, State.APIPROPERTY, origSM.getElementAttrLimit());
++ }
++ return securityManager;
++ }
++ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8022940-enhance_corba_translations.patch b/java/openjdk6/files/icedtea/openjdk/8022940-enhance_corba_translations.patch
new file mode 100644
index 000000000000..f5b6cc769960
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8022940-enhance_corba_translations.patch
@@ -0,0 +1,41 @@
+# HG changeset patch
+# User msheppar
+# Date 1376928111 -3600
+# Mon Aug 19 17:01:51 2013 +0100
+# Node ID b449df31dbfbf08d0f58a887649c2acacd5d834f
+# Parent 2a415f9ee0976719ac79e6e5e2b1f00b29636427
+8022940: Enhance CORBA translations
+Reviewed-by: coffeys, alanb, skoivu
+
+diff -r 2a415f9ee097 -r b449df31dbfb src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java
+--- corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java Thu Jul 18 17:22:25 2013 -0700
++++ corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java Mon Aug 19 17:01:51 2013 +0100
+@@ -905,28 +905,4 @@
+
+ return contents.toString();
+ }
+-
+- public static void main(String[] args) {
+-
+- Class remoteInterface = java.rmi.Remote.class;
+-
+- if( args.length > 0 ) {
+- String className = args[0];
+- try {
+- remoteInterface = Class.forName(className);
+- } catch(Exception e) {
+- e.printStackTrace();
+- System.exit(-1);
+- }
+- }
+-
+- System.out.println("Building name translation for " + remoteInterface);
+- try {
+- IDLNameTranslator nameTranslator =
+- IDLNameTranslatorImpl.get(remoteInterface);
+- System.out.println(nameTranslator);
+- } catch(IllegalStateException ise) {
+- ise.printStackTrace();
+- }
+- }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/8023457-tracing_mutex.patch b/java/openjdk6/files/icedtea/openjdk/8023457-tracing_mutex.patch
new file mode 100644
index 000000000000..0c55c0cf13ce
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8023457-tracing_mutex.patch
@@ -0,0 +1,79 @@
+# HG changeset patch
+# User mgronlun
+# Date 1382034480 -3600
+# Thu Oct 17 19:28:00 2013 +0100
+# Node ID 4b3487aa553cca3fb7ecb74d284b9524d0bf5bf8
+# Parent 3091721c83780cbb9a946f05007651e0bd09490b
+8023457: Event based tracing framework needs a mutex for thread groups
+Reviewed-by: acorn, sla
+
+diff -r 3091721c8378 -r 4b3487aa553c src/share/vm/runtime/mutexLocker.cpp
+--- hotspot/src/share/vm/runtime/mutexLocker.cpp Sat Aug 24 00:14:46 2013 -0700
++++ hotspot/src/share/vm/runtime/mutexLocker.cpp Thu Oct 17 19:28:00 2013 +0100
+@@ -134,12 +134,16 @@
+
+ Mutex* Management_lock = NULL;
+ Monitor* Service_lock = NULL;
+-Mutex* Stacktrace_lock = NULL;
++Monitor* PeriodicTask_lock = NULL;
+
++#ifdef INCLUDE_TRACE
+ Monitor* JfrQuery_lock = NULL;
++Mutex* JfrStacktrace_lock = NULL;
+ Monitor* JfrMsg_lock = NULL;
+ Mutex* JfrBuffer_lock = NULL;
+ Mutex* JfrStream_lock = NULL;
++Mutex* JfrThreadGroups_lock = NULL;
++#endif
+
+ #define MAX_NUM_MUTEX 128
+ static Monitor * _mutex_array[MAX_NUM_MUTEX];
+@@ -215,7 +219,6 @@
+ def(Patching_lock , Mutex , special, true ); // used for safepointing and code patching.
+ def(ObjAllocPost_lock , Monitor, special, false);
+ def(Service_lock , Monitor, special, true ); // used for service thread operations
+- def(Stacktrace_lock , Mutex, special, true ); // used for JFR stacktrace database
+ def(JmethodIdCreation_lock , Mutex , leaf, true ); // used for creating jmethodIDs.
+
+ def(SystemDictionary_lock , Monitor, leaf, true ); // lookups done by VM thread
+@@ -279,12 +282,18 @@
+ def(Debug2_lock , Mutex , nonleaf+4, true );
+ def(Debug3_lock , Mutex , nonleaf+4, true );
+ def(ProfileVM_lock , Monitor, nonleaf+4, false); // used for profiling of the VMThread
+- def(CompileThread_lock , Monitor, nonleaf+5, false );
++ def(CompileThread_lock , Monitor, nonleaf+5, false);
++ def(PeriodicTask_lock , Monitor, nonleaf+5, true);
+
++#ifdef INCLUDE_TRACE
+ def(JfrQuery_lock , Monitor, nonleaf, true); // JFR locks, keep these in consecutive order
+ def(JfrMsg_lock , Monitor, nonleaf+2, true);
+ def(JfrBuffer_lock , Mutex, nonleaf+3, true);
++ def(JfrThreadGroups_lock , Mutex, nonleaf+1, true);
+ def(JfrStream_lock , Mutex, nonleaf+4, true);
++ def(JfrStacktrace_lock , Mutex, special, true );
++#endif
++
+ }
+
+ GCMutexLocker::GCMutexLocker(Monitor * mutex) {
+diff -r 3091721c8378 -r 4b3487aa553c src/share/vm/runtime/mutexLocker.hpp
+--- hotspot/src/share/vm/runtime/mutexLocker.hpp Sat Aug 24 00:14:46 2013 -0700
++++ hotspot/src/share/vm/runtime/mutexLocker.hpp Thu Oct 17 19:28:00 2013 +0100
+@@ -136,12 +136,16 @@
+
+ extern Mutex* Management_lock; // a lock used to serialize JVM management
+ extern Monitor* Service_lock; // a lock used for service thread operation
+-extern Mutex* Stacktrace_lock; // used to guard access to the stacktrace table
++extern Monitor* PeriodicTask_lock; // protects the periodic task structure
+
++#ifdef INCLUDE_TRACE
++extern Mutex* JfrStacktrace_lock; // used to guard access to the JFR stacktrace table
+ extern Monitor* JfrQuery_lock; // protects JFR use
+ extern Monitor* JfrMsg_lock; // protects JFR messaging
+ extern Mutex* JfrBuffer_lock; // protects JFR buffer operations
+ extern Mutex* JfrStream_lock; // protects JFR stream access
++extern Mutex* JfrThreadGroups_lock; // protects JFR access to Thread Groups
++#endif
+
+ // A MutexLocker provides mutual exclusion with respect to a given mutex
+ // for the scope which contains the locker. The lock is an OS lock, not
diff --git a/java/openjdk6/files/icedtea/openjdk/8023478-hs_crash.patch b/java/openjdk6/files/icedtea/openjdk/8023478-hs_crash.patch
new file mode 100644
index 000000000000..d9933779a949
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8023478-hs_crash.patch
@@ -0,0 +1,21 @@
+# HG changeset patch
+# User kevinw
+# Date 1379364550 25200
+# Mon Sep 16 13:49:10 2013 -0700
+# Node ID e8d1979fe077eda9a94528c4b76dd4c5243d5dec
+# Parent 2660219948088d89dd3fc285e093dab2520349e5
+8023478: Test fails with HS crash in GCNotifier.
+Reviewed-by: sla
+
+diff -r 266021994808 -r e8d1979fe077 src/share/vm/services/gcNotifier.cpp
+--- hotspot/src/share/vm/services/gcNotifier.cpp Fri Aug 02 12:26:46 2013 +0100
++++ hotspot/src/share/vm/services/gcNotifier.cpp Mon Sep 16 13:49:10 2013 -0700
+@@ -209,7 +209,7 @@
+ GCNotificationRequest *request = getRequest();
+ if (request != NULL) {
+ NotificationMark nm(request);
+- Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, THREAD);
++ Handle objGcInfo = createGcInfo(request->gcManager, request->gcStatInfo, CHECK);
+
+ Handle objName = java_lang_String::create_from_str(request->gcManager->name(), CHECK);
+ Handle objAction = java_lang_String::create_from_str(request->gcAction, CHECK);
diff --git a/java/openjdk6/files/icedtea/openjdk/8023683-enhance_class_file_parsing.patch b/java/openjdk6/files/icedtea/openjdk/8023683-enhance_class_file_parsing.patch
new file mode 100644
index 000000000000..6bd4199dea8c
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8023683-enhance_class_file_parsing.patch
@@ -0,0 +1,35 @@
+# HG changeset patch
+# User iklam
+# Date 1377328486 25200
+# Sat Aug 24 00:14:46 2013 -0700
+# Node ID 3091721c83780cbb9a946f05007651e0bd09490b
+# Parent bbd051c9089f61c65fe7d95487d47920164c7ee0
+8023683: Enhance class file parsing
+Summary: Use the value returned by REALLOC_RESOURCE_ARRAY()
+Reviewed-by: coleenp, ahgross
+
+diff -r bbd051c9089f -r 3091721c8378 src/share/vm/classfile/classFileParser.cpp
+--- hotspot/src/share/vm/classfile/classFileParser.cpp Mon Jul 15 10:22:43 2013 +0400
++++ hotspot/src/share/vm/classfile/classFileParser.cpp Sat Aug 24 00:14:46 2013 -0700
+@@ -1821,8 +1821,8 @@
+ }
+ if (lvt_cnt == max_lvt_cnt) {
+ max_lvt_cnt <<= 1;
+- REALLOC_RESOURCE_ARRAY(u2, localvariable_table_length, lvt_cnt, max_lvt_cnt);
+- REALLOC_RESOURCE_ARRAY(u2*, localvariable_table_start, lvt_cnt, max_lvt_cnt);
++ localvariable_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_table_length, lvt_cnt, max_lvt_cnt);
++ localvariable_table_start = REALLOC_RESOURCE_ARRAY(u2*, localvariable_table_start, lvt_cnt, max_lvt_cnt);
+ }
+ localvariable_table_start[lvt_cnt] =
+ parse_localvariable_table(code_length,
+@@ -1851,8 +1851,8 @@
+ // Parse local variable type table
+ if (lvtt_cnt == max_lvtt_cnt) {
+ max_lvtt_cnt <<= 1;
+- REALLOC_RESOURCE_ARRAY(u2, localvariable_type_table_length, lvtt_cnt, max_lvtt_cnt);
+- REALLOC_RESOURCE_ARRAY(u2*, localvariable_type_table_start, lvtt_cnt, max_lvtt_cnt);
++ localvariable_type_table_length = REALLOC_RESOURCE_ARRAY(u2, localvariable_type_table_length, lvtt_cnt, max_lvtt_cnt);
++ localvariable_type_table_start = REALLOC_RESOURCE_ARRAY(u2*, localvariable_type_table_start, lvtt_cnt, max_lvtt_cnt);
+ }
+ localvariable_type_table_start[lvtt_cnt] =
+ parse_localvariable_table(code_length,
diff --git a/java/openjdk6/files/icedtea/openjdk/8023964-ignore_test.patch b/java/openjdk6/files/icedtea/openjdk/8023964-ignore_test.patch
new file mode 100644
index 000000000000..89a6bb468e47
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8023964-ignore_test.patch
@@ -0,0 +1,29 @@
+# HG changeset patch
+# User coffeys
+# Date 1378485490 25200
+# Fri Sep 06 09:38:10 2013 -0700
+# Node ID 44a49c18eba21f97222a2cde09f6536a7f365363
+# Parent 6c0b775b1ff2a0a0ba0fe797cfe18c511f9ee3c1
+8023964: java/io/IOException/LastErrorString.java should be @ignore-d
+Reviewed-by: alanb
+
+diff -r 6c0b775b1ff2 -r 44a49c18eba2 test/java/io/IOException/LastErrorString.java
+--- jdk/test/java/io/IOException/LastErrorString.java Fri Aug 09 13:50:13 2013 +0100
++++ jdk/test/java/io/IOException/LastErrorString.java Fri Sep 06 09:38:10 2013 -0700
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 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
+@@ -22,7 +22,8 @@
+ */
+
+ /* @test
+- @bug 4167937
++ @bug 4167937 8023964
++ @ignore Test truncates system files when run as root, see 7042603
+ @summary Test code paths that use the JVM_LastErrorString procedure
+ */
+
diff --git a/java/openjdk6/files/icedtea/openjdk/8024914-swapped_usage.patch b/java/openjdk6/files/icedtea/openjdk/8024914-swapped_usage.patch
new file mode 100644
index 000000000000..29ace4855155
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8024914-swapped_usage.patch
@@ -0,0 +1,58 @@
+# HG changeset patch
+# User tschatzl
+# Date 1379412251 -7200
+# Tue Sep 17 12:04:11 2013 +0200
+# Node ID d0b5dc55e72cde11331399cbb960458b8f45ea4a
+# Parent 41d2a089e66401c8815af0c6b6efd2af9aeabe99
+8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
+Summary: Incorrect usage of idx_t where bm_word_t is appropriate.
+Reviewed-by: tschatzl, brutisso
+Contributed-by: Dan Horak <dhorak@redhat.com>
+
+diff -r 41d2a089e664 -r d0b5dc55e72c src/share/vm/utilities/bitMap.inline.hpp
+--- hotspot/src/share/vm/utilities/bitMap.inline.hpp Fri Oct 04 12:22:34 2013 -0400
++++ hotspot/src/share/vm/utilities/bitMap.inline.hpp Tue Sep 17 12:04:11 2013 +0200
+@@ -52,16 +52,16 @@
+
+ inline bool BitMap::par_set_bit(idx_t bit) {
+ verify_index(bit);
+- volatile idx_t* const addr = word_addr(bit);
+- const idx_t mask = bit_mask(bit);
+- idx_t old_val = *addr;
++ volatile bm_word_t* const addr = word_addr(bit);
++ const bm_word_t mask = bit_mask(bit);
++ bm_word_t old_val = *addr;
+
+ do {
+- const idx_t new_val = old_val | mask;
++ const bm_word_t new_val = old_val | mask;
+ if (new_val == old_val) {
+ return false; // Someone else beat us to it.
+ }
+- const idx_t cur_val = (idx_t) Atomic::cmpxchg_ptr((void*) new_val,
++ const bm_word_t cur_val = (bm_word_t) Atomic::cmpxchg_ptr((void*) new_val,
+ (volatile void*) addr,
+ (void*) old_val);
+ if (cur_val == old_val) {
+@@ -73,16 +73,16 @@
+
+ inline bool BitMap::par_clear_bit(idx_t bit) {
+ verify_index(bit);
+- volatile idx_t* const addr = word_addr(bit);
+- const idx_t mask = ~bit_mask(bit);
+- idx_t old_val = *addr;
++ volatile bm_word_t* const addr = word_addr(bit);
++ const bm_word_t mask = ~bit_mask(bit);
++ bm_word_t old_val = *addr;
+
+ do {
+- const idx_t new_val = old_val & mask;
++ const bm_word_t new_val = old_val & mask;
+ if (new_val == old_val) {
+ return false; // Someone else beat us to it.
+ }
+- const idx_t cur_val = (idx_t) Atomic::cmpxchg_ptr((void*) new_val,
++ const bm_word_t cur_val = (bm_word_t) Atomic::cmpxchg_ptr((void*) new_val,
+ (volatile void*) addr,
+ (void*) old_val);
+ if (cur_val == old_val) {
diff --git a/java/openjdk6/files/icedtea/openjdk/8025128-createtempfile_absolute_prefix.patch b/java/openjdk6/files/icedtea/openjdk/8025128-createtempfile_absolute_prefix.patch
new file mode 100644
index 000000000000..d2acd0d22d1a
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/8025128-createtempfile_absolute_prefix.patch
@@ -0,0 +1,139 @@
+# HG changeset patch
+# User dxu
+# Date 1383019831 0
+# Tue Oct 29 04:10:31 2013 +0000
+# Node ID 008e31b76d415f263617e710f19da6254135817f
+# Parent 8459b68eb028734b2153266176538e1eddbb87be
+8025128: File.createTempFile fails if prefix is absolute path
+Reviewed-by: alanb, darcy
+
+diff -r 8459b68eb028 -r 008e31b76d41 src/share/classes/java/io/File.java
+--- jdk/src/share/classes/java/io/File.java Tue Oct 29 03:49:40 2013 +0000
++++ jdk/src/share/classes/java/io/File.java Tue Oct 29 04:10:31 2013 +0000
+@@ -1801,11 +1801,19 @@
+ } else {
+ n = Math.abs(n);
+ }
+- String name = prefix + Long.toString(n) + suffix;
+- File f = new File(dir, name);
+- if (!name.equals(f.getName()))
+- throw new IOException("Unable to create temporary file");
+- return f;
++
++ // Use only the file name from the supplied prefix
++ prefix = (new File(prefix)).getName();
++
++ String name = prefix + Long.toString(n) + suffix;
++ File f = new File(dir, name);
++ if (!name.equals(f.getName())) {
++ if (System.getSecurityManager() != null)
++ throw new IOException("Unable to create temporary file");
++ else
++ throw new IOException("Unable to create temporary file, " + f);
++ }
++ return f;
+ }
+
+ private static boolean checkAndCreate(String filename, SecurityManager sm,
+diff -r 8459b68eb028 -r 008e31b76d41 test/java/io/File/createTempFile/SpecialTempFile.java
+--- jdk/test/java/io/File/createTempFile/SpecialTempFile.java Tue Oct 29 03:49:40 2013 +0000
++++ jdk/test/java/io/File/createTempFile/SpecialTempFile.java Tue Oct 29 04:10:31 2013 +0000
+@@ -23,7 +23,7 @@
+
+ /*
+ * @test
+- * @bug 8013827 8011950
++ * @bug 8013827 8011950 8025128
+ * @summary Check whether File.createTempFile can handle special parameters
+ * on Windows platforms
+ * @author Dan Xu
+@@ -34,7 +34,9 @@
+
+ public class SpecialTempFile {
+
+- private static void test(String name, String[] prefix, String[] suffix) {
++ private static void test(String name, String[] prefix, String[] suffix,
++ boolean expectedException) throws IOException
++ {
+ if (prefix == null || suffix == null
+ || prefix.length != suffix.length)
+ {
+@@ -42,39 +44,59 @@
+ }
+
+ final String exceptionMsg = "Unable to create temporary file";
+- final String errMsg = "IOException is expected";
+
+ for (int i = 0; i < prefix.length; i++) {
+ boolean exceptionThrown = false;
+ File f = null;
+- System.out.println("In test " + name
+- + ", creating temp file with prefix, "
+- + prefix[i] + ", suffix, " + suffix[i]);
+- try {
+- f = File.createTempFile(prefix[i], suffix[i]);
+- } catch (IOException e) {
+- if (exceptionMsg.equals(e.getMessage()))
+- exceptionThrown = true;
+- else
+- System.out.println("Wrong error message:" + e.getMessage());
++
++ String[] dirs = { null, "." };
++
++ for (String dir : dirs ) {
++ System.out.println("In test " + name +
++ ", creating temp file with prefix, " +
++ prefix[i] + ", suffix, " + suffix[i] +
++ ", in dir, " + dir);
++
++ try {
++ if (dir == null || dir.isEmpty())
++ f = File.createTempFile(prefix[i], suffix[i]);
++ else
++ f = File.createTempFile(prefix[i], suffix[i], new File(dir));
++ } catch (IOException e) {
++ if (expectedException) {
++ if (e.getMessage().startsWith(exceptionMsg))
++ exceptionThrown = true;
++ else
++ System.out.println("Wrong error message:" +
++ e.getMessage());
++ } else {
++ throw e;
++ }
++ }
++
++ if (expectedException && (!exceptionThrown || f != null))
++ throw new RuntimeException("IOException is expected");
+ }
+- if (!exceptionThrown || f != null)
+- throw new RuntimeException(errMsg);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
++ // Test JDK-8025128
++ String[] goodPre = { "///..///", "/foo" };
++ String[] goodSuf = { ".temp", ".tmp" };
++ test("goodName", goodPre, goodSuf, false);
++
++ // Test JDK-8011950
++ String[] slashPre = { "temp", "///..///", "/foo" };
++ String[] slashSuf = { "///..///..", "///..///..", "///..///.." };
++ test("SlashedName", slashPre, slashSuf, true);
++
+ if (!System.getProperty("os.name").startsWith("Windows"))
+ return;
+
+ // Test JDK-8013827
+ String[] resvPre = { "LPT1.package.zip", "com7.4.package.zip" };
+ String[] resvSuf = { ".temp", ".temp" };
+- test("ReservedName", resvPre, resvSuf);
+-
+- // Test JDK-8011950
+- String[] slashPre = { "///..///", "temp", "///..///" };
+- String[] slashSuf = { ".temp", "///..///..", "///..///.." };
+- test("SlashedName", slashPre, slashSuf);
++ test("ReservedName", resvPre, resvSuf, true);
+ }
+ }
diff --git a/java/openjdk6/files/icedtea/openjdk/oj6-19-fix_8010118_test_cases.patch b/java/openjdk6/files/icedtea/openjdk/oj6-19-fix_8010118_test_cases.patch
new file mode 100644
index 000000000000..313097b8600c
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/oj6-19-fix_8010118_test_cases.patch
@@ -0,0 +1,499 @@
+# HG changeset patch
+# User andrew
+# Date 1382719863 -3600
+# Fri Oct 25 17:51:03 2013 +0100
+# Node ID d4fca2113b280a7db03b67caae22e0ceafb51b89
+# Parent 566f427de7079a0ed32c2f625c952dcc45c348e3
+OPENJDK6-19: Fix test cases from 8010118 to work with OpenJDK 6
+Reviewed-by: omajid
+
+diff -r 566f427de707 -r d4fca2113b28 test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java
+--- jdk/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java Tue Jun 03 13:28:16 2008 -0700
++++ jdk/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java Fri Oct 25 17:51:03 2013 +0100
+@@ -23,16 +23,12 @@
+
+ import com.sun.tools.classfile.*;
+ import static com.sun.tools.classfile.ConstantPool.*;
++
+ import java.io.File;
+ import java.io.IOException;
+ import java.lang.reflect.InvocationTargetException;
+-import java.nio.file.FileVisitResult;
+-import java.nio.file.Files;
+-import java.nio.file.Path;
+-import java.nio.file.Paths;
+-import java.nio.file.SimpleFileVisitor;
+-import java.nio.file.attribute.BasicFileAttributes;
+ import java.util.ArrayList;
++import java.util.Arrays;
+ import java.util.List;
+ import java.util.Set;
+ import java.util.concurrent.Callable;
+@@ -53,7 +49,7 @@
+ private static int numThreads = 3;
+ private static boolean verbose = false;
+ public static void main(String[] args) throws Exception {
+- List<Path> classes = new ArrayList<>();
++ List<File> classes = new ArrayList<File>();
+ String testclasses = System.getProperty("test.classes", ".");
+ int i = 0;
+ while (i < args.length) {
+@@ -61,11 +57,11 @@
+ if (arg.equals("-v")) {
+ verbose = true;
+ } else {
+- Path p = Paths.get(testclasses, arg);
+- if (!p.toFile().exists()) {
++ File f = new File(testclasses, arg);
++ if (!f.exists()) {
+ throw new IllegalArgumentException(arg + " does not exist");
+ }
+- classes.add(p);
++ classes.add(f);
+ }
+ }
+ if (classes.isEmpty()) {
+@@ -81,7 +77,7 @@
+ }
+ }
+
+- private final List<String> csMethodsMissingAnnotation = new ArrayList<>();
++ private final List<String> csMethodsMissingAnnotation = new ArrayList<String>();
+ private final java.lang.reflect.Method mhnCallerSensitiveMethod;
+ public CallerSensitiveFinder(String... methods) throws Exception {
+ super(methods);
+@@ -91,12 +87,114 @@
+ static java.lang.reflect.Method getIsCallerSensitiveMethod()
+ throws ClassNotFoundException, NoSuchMethodException
+ {
+- Class<?> cls = Class.forName("java.lang.invoke.MethodHandleNatives");
++ Class<?> cls = CallerSensitiveFinder.class;
+ java.lang.reflect.Method m = cls.getDeclaredMethod("isCallerSensitiveMethod", Class.class, String.class);
+ m.setAccessible(true);
+ return m;
+ }
+
++ // Needs to match method in 7's java.lang.invoke.MethodHandleNatives
++ private static boolean isCallerSensitiveMethod(Class<?> defc, String method) {
++ if ("doPrivileged".equals(method) ||
++ "doPrivilegedWithCombiner".equals(method))
++ return defc == java.security.AccessController.class;
++ else if ("checkMemberAccess".equals(method))
++ return defc == java.lang.SecurityManager.class;
++ else if ("getUnsafe".equals(method))
++ return defc == sun.misc.Unsafe.class;
++ else if ("invoke".equals(method))
++ return defc == java.lang.reflect.Method.class;
++ else if ("get".equals(method) ||
++ "getBoolean".equals(method) ||
++ "getByte".equals(method) ||
++ "getChar".equals(method) ||
++ "getShort".equals(method) ||
++ "getInt".equals(method) ||
++ "getLong".equals(method) ||
++ "getFloat".equals(method) ||
++ "getDouble".equals(method) ||
++ "set".equals(method) ||
++ "setBoolean".equals(method) ||
++ "setByte".equals(method) ||
++ "setChar".equals(method) ||
++ "setShort".equals(method) ||
++ "setInt".equals(method) ||
++ "setLong".equals(method) ||
++ "setFloat".equals(method) ||
++ "setDouble".equals(method))
++ return defc == java.lang.reflect.Field.class;
++ else if ("newInstance".equals(method)) {
++ if (defc == java.lang.reflect.Constructor.class) return true;
++ if (defc == java.lang.Class.class) return true;
++ } else if ("getFields".equals(method))
++ return defc == java.lang.Class.class ||
++ defc == javax.sql.rowset.serial.SerialJavaObject.class;
++ else if ("forName".equals(method) ||
++ "getClassLoader".equals(method) ||
++ "getClasses".equals(method) ||
++ "getMethods".equals(method) ||
++ "getConstructors".equals(method) ||
++ "getDeclaredClasses".equals(method) ||
++ "getDeclaredFields".equals(method) ||
++ "getDeclaredMethods".equals(method) ||
++ "getDeclaredConstructors".equals(method) ||
++ "getField".equals(method) ||
++ "getMethod".equals(method) ||
++ "getConstructor".equals(method) ||
++ "getDeclaredField".equals(method) ||
++ "getDeclaredMethod".equals(method) ||
++ "getDeclaredConstructor".equals(method) ||
++ "getDeclaringClass".equals(method) ||
++ "getEnclosingClass".equals(method) ||
++ "getEnclosingMethod".equals(method) ||
++ "getEnclosingConstructor".equals(method))
++ return defc == java.lang.Class.class;
++ else if ("getConnection".equals(method) ||
++ "getDriver".equals(method) ||
++ "getDrivers".equals(method) ||
++ "deregisterDriver".equals(method))
++ return defc == java.sql.DriverManager.class;
++ else if ("newUpdater".equals(method)) {
++ if (defc == java.util.concurrent.atomic.AtomicIntegerFieldUpdater.class) return true;
++ if (defc == java.util.concurrent.atomic.AtomicLongFieldUpdater.class) return true;
++ if (defc == java.util.concurrent.atomic.AtomicReferenceFieldUpdater.class) return true;
++ } else if ("getContextClassLoader".equals(method))
++ return defc == java.lang.Thread.class;
++ else if ("getPackage".equals(method) ||
++ "getPackages".equals(method))
++ return defc == java.lang.Package.class;
++ else if ("getParent".equals(method) ||
++ "getSystemClassLoader".equals(method))
++ return defc == java.lang.ClassLoader.class;
++ else if ("load".equals(method) ||
++ "loadLibrary".equals(method)) {
++ if (defc == java.lang.Runtime.class) return true;
++ if (defc == java.lang.System.class) return true;
++ } else if ("getCallerClass".equals(method)) {
++ if (defc == sun.reflect.Reflection.class) return true;
++ if (defc == java.lang.System.class) return true;
++ } else if ("getCallerClassLoader".equals(method))
++ return defc == java.lang.ClassLoader.class;
++ else if ("registerAsParallelCapable".equals(method))
++ return defc == java.lang.ClassLoader.class;
++ else if ("getInvocationHandler".equals(method) ||
++ "getProxyClass".equals(method) ||
++ "newProxyInstance".equals(method))
++ return defc == java.lang.reflect.Proxy.class;
++ else if ("getBundle".equals(method) ||
++ "clearCache".equals(method))
++ return defc == java.util.ResourceBundle.class;
++ else if ("getType".equals(method))
++ return defc == java.io.ObjectStreamField.class;
++ else if ("forClass".equals(method))
++ return defc == java.io.ObjectStreamClass.class;
++ else if ("getLogger".equals(method))
++ return defc == java.util.logging.Logger.class;
++ else if ("getAnonymousLogger".equals(method))
++ return defc == java.util.logging.Logger.class;
++ return false;
++ }
++
+ boolean inMethodHandlesList(String classname, String method) {
+ Class<?> cls;
+ try {
+@@ -104,19 +202,21 @@
+ false,
+ ClassLoader.getSystemClassLoader());
+ return (Boolean) mhnCallerSensitiveMethod.invoke(null, cls, method);
+- } catch (ClassNotFoundException|IllegalAccessException e) {
++ } catch (ClassNotFoundException e) {
++ throw new RuntimeException(e);
++ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e.getCause());
+ }
+ }
+
+- public List<String> run(List<Path> classes) throws IOException, InterruptedException,
++ public List<String> run(List<File> classes) throws IOException, InterruptedException,
+ ExecutionException, ConstantPoolException
+ {
+ ExecutorService pool = Executors.newFixedThreadPool(numThreads);
+- for (Path path : classes) {
+- ClassFileReader reader = ClassFileReader.newInstance(path.toFile());
++ for (File path : classes) {
++ ClassFileReader reader = ClassFileReader.newInstance(path);
+ for (ClassFile cf : reader.getClassFiles()) {
+ String classFileName = cf.getName();
+ // for each ClassFile
+@@ -192,56 +292,46 @@
+ }
+
+ static class PlatformClassPath {
+- static List<Path> getJREClasses() throws IOException {
+- List<Path> result = new ArrayList<Path>();
+- Path home = Paths.get(System.getProperty("java.home"));
++ static List<File> getJREClasses() throws IOException {
++ List<File> result = new ArrayList<File>();
++ File home = new File(System.getProperty("java.home"));
+
+- if (home.endsWith("jre")) {
++ if (home.toString().endsWith("jre")) {
+ // jar files in <javahome>/jre/lib
+ // skip <javahome>/lib
+- result.addAll(addJarFiles(home.resolve("lib")));
+- } else if (home.resolve("lib").toFile().exists()) {
++ result.addAll(addJarFiles(new File(home, "lib")));
++ } else if (new File(home, "lib").exists()) {
+ // either a JRE or a jdk build image
+- File classes = home.resolve("classes").toFile();
++ File classes = new File(home, "classes");
+ if (classes.exists() && classes.isDirectory()) {
+ // jdk build outputdir
+- result.add(classes.toPath());
++ result.add(classes);
+ }
+ // add other JAR files
+- result.addAll(addJarFiles(home.resolve("lib")));
++ result.addAll(addJarFiles(new File(home, "lib")));
+ } else {
+ throw new RuntimeException("\"" + home + "\" not a JDK home");
+ }
+ return result;
+ }
+
+- static List<Path> addJarFiles(final Path root) throws IOException {
+- final List<Path> result = new ArrayList<Path>();
+- final Path ext = root.resolve("ext");
+- Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
+- @Override
+- public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
+- throws IOException {
+- if (dir.equals(root) || dir.equals(ext)) {
+- return FileVisitResult.CONTINUE;
+- } else {
+- // skip other cobundled JAR files
+- return FileVisitResult.SKIP_SUBTREE;
+- }
+- }
+-
+- @Override
+- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+- throws IOException {
+- File f = file.toFile();
++ static List<File> addJarFiles(final File root) throws IOException {
++ final List<File> result = new ArrayList<File>();
++ final File ext = new File(root, "ext");
++ final List<File> files = new ArrayList<File>();
++ for (String s : root.list())
++ files.add(new File(root, s));
++ for (String s : ext.list())
++ files.add(new File(ext, s));
++ for (File f : files) {
++ if (f.isFile()) {
+ String fn = f.getName();
+ // parse alt-rt.jar as well
+ if (fn.endsWith(".jar") && !fn.equals("jfxrt.jar")) {
+- result.add(file);
++ result.add(f);
+ }
+- return FileVisitResult.CONTINUE;
+ }
+- });
++ }
+ return result;
+ }
+ }
+diff -r 566f427de707 -r d4fca2113b28 test/sun/reflect/CallerSensitive/ClassFileReader.java
+--- jdk/test/sun/reflect/CallerSensitive/ClassFileReader.java Tue Jun 03 13:28:16 2008 -0700
++++ jdk/test/sun/reflect/CallerSensitive/ClassFileReader.java Fri Oct 25 17:51:03 2013 +0100
+@@ -23,12 +23,8 @@
+
+ import com.sun.tools.classfile.ClassFile;
+ import com.sun.tools.classfile.ConstantPoolException;
++
+ import java.io.*;
+-import java.nio.file.FileVisitResult;
+-import java.nio.file.Files;
+-import java.nio.file.Path;
+-import java.nio.file.SimpleFileVisitor;
+-import java.nio.file.attribute.BasicFileAttributes;
+ import java.util.*;
+ import java.util.jar.JarEntry;
+ import java.util.jar.JarFile;
+@@ -47,28 +43,28 @@
+ }
+
+ if (path.isDirectory()) {
+- return new DirectoryReader(path.toPath());
++ return new DirectoryReader(path);
+ } else if (path.getName().endsWith(".jar")) {
+- return new JarFileReader(path.toPath());
++ return new JarFileReader(path);
+ } else {
+- return new ClassFileReader(path.toPath());
++ return new ClassFileReader(path);
+ }
+ }
+
+ /**
+ * Returns a ClassFileReader instance of a given JarFile.
+ */
+- public static ClassFileReader newInstance(Path path, JarFile jf) throws IOException {
++ public static ClassFileReader newInstance(File path, JarFile jf) throws IOException {
+ return new JarFileReader(path, jf);
+ }
+
+- protected final Path path;
++ protected final File path;
+ protected final String baseFileName;
+- private ClassFileReader(Path path) {
++ private ClassFileReader(File path) {
+ this.path = path;
+- this.baseFileName = path.getFileName() != null
+- ? path.getFileName().toString()
+- : path.toString();
++ this.baseFileName = path.getName().equals("")
++ ? path.toString()
++ : path.getName();
+ }
+
+ public String getFileName() {
+@@ -104,10 +100,10 @@
+ };
+ }
+
+- protected ClassFile readClassFile(Path p) throws IOException {
++ protected ClassFile readClassFile(File p) throws IOException {
+ InputStream is = null;
+ try {
+- is = Files.newInputStream(p);
++ is = new FileInputStream(p);
+ return ClassFile.read(is);
+ } catch (ConstantPoolException e) {
+ throw new ClassFileError(e);
+@@ -150,7 +146,7 @@
+ }
+
+ private static class DirectoryReader extends ClassFileReader {
+- DirectoryReader(Path path) throws IOException {
++ DirectoryReader(File path) throws IOException {
+ super(path);
+ }
+
+@@ -158,17 +154,17 @@
+ if (name.indexOf('.') > 0) {
+ int i = name.lastIndexOf('.');
+ String pathname = name.replace('.', File.separatorChar) + ".class";
+- Path p = path.resolve(pathname);
+- if (!p.toFile().exists()) {
+- p = path.resolve(pathname.substring(0, i) + "$" +
+- pathname.substring(i+1, pathname.length()));
++ File p = new File(path, pathname);
++ if (!p.exists()) {
++ p = new File(path, pathname.substring(0, i) + "$" +
++ pathname.substring(i+1, pathname.length()));
+ }
+- if (p.toFile().exists()) {
++ if (p.exists()) {
+ return readClassFile(p);
+ }
+ } else {
+- Path p = path.resolve(name + ".class");
+- if (p.toFile().exists()) {
++ File p = new File(path, name + ".class");
++ if (p.exists()) {
+ return readClassFile(p);
+ }
+ }
+@@ -184,22 +180,24 @@
+ };
+ }
+
+- private List<Path> walkTree(Path dir) throws IOException {
+- final List<Path> files = new ArrayList<Path>();
+- Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
+- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+- throws IOException {
+- if (file.toFile().getName().endsWith(".class")) {
+- files.add(file);
++ private List<File> walkTree(File dir) throws IOException {
++ final List<File> files = new ArrayList<File>();
++ final List<String> dirContents = Arrays.asList(dir.list());
++ for (String file : dirContents) {
++ File f = new File(dir, file);
++ if (f.isDirectory())
++ files.addAll(walkTree(f));
++ else {
++ if (f.getName().endsWith(".class")) {
++ files.add(f);
+ }
+- return FileVisitResult.CONTINUE;
+ }
+- });
++ }
+ return files;
+ }
+
+ class DirectoryIterator implements Iterator<ClassFile> {
+- private List<Path> entries;
++ private List<File> entries;
+ private int index = 0;
+ DirectoryIterator() throws IOException {
+ entries = walkTree(path);
+@@ -214,7 +212,7 @@
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+- Path path = entries.get(index++);
++ File path = entries.get(index++);
+ try {
+ return readClassFile(path);
+ } catch (IOException e) {
+@@ -230,10 +228,10 @@
+
+ private static class JarFileReader extends ClassFileReader {
+ final JarFile jarfile;
+- JarFileReader(Path path) throws IOException {
+- this(path, new JarFile(path.toFile()));
++ JarFileReader(File path) throws IOException {
++ this(path, new JarFile(path));
+ }
+- JarFileReader(Path path, JarFile jf) throws IOException {
++ JarFileReader(File path, JarFile jf) throws IOException {
+ super(path);
+ this.jarfile = jf;
+ }
+diff -r 566f427de707 -r d4fca2113b28 test/sun/reflect/CallerSensitive/MethodFinder.java
+--- jdk/test/sun/reflect/CallerSensitive/MethodFinder.java Tue Jun 03 13:28:16 2008 -0700
++++ jdk/test/sun/reflect/CallerSensitive/MethodFinder.java Fri Oct 25 17:51:03 2013 +0100
+@@ -121,10 +121,6 @@
+ return false;
+ }
+
+- public Boolean visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Void p) {
+- return false;
+- }
+-
+ public Boolean visitLong(CONSTANT_Long_info info, Void p) {
+ return false;
+ }
+@@ -133,14 +129,6 @@
+ return false;
+ }
+
+- public Boolean visitMethodHandle(CONSTANT_MethodHandle_info info, Void p) {
+- return false;
+- }
+-
+- public Boolean visitMethodType(CONSTANT_MethodType_info info, Void p) {
+- return false;
+- }
+-
+ public Boolean visitString(CONSTANT_String_info info, Void p) {
+ return false;
+ }
+@@ -198,4 +186,3 @@
+ }
+ };
+ }
+-
+diff -r 566f427de707 -r d4fca2113b28 test/sun/reflect/CallerSensitive/MissingCallerSensitive.java
+--- jdk/test/sun/reflect/CallerSensitive/MissingCallerSensitive.java Tue Jun 03 13:28:16 2008 -0700
++++ jdk/test/sun/reflect/CallerSensitive/MissingCallerSensitive.java Fri Oct 25 17:51:03 2013 +0100
+@@ -30,14 +30,13 @@
+ * @run main/othervm MissingCallerSensitive
+ */
+
+-import java.nio.file.Path;
+-import java.nio.file.Paths;
++import java.io.File;
+ import java.util.*;
+ public class MissingCallerSensitive {
+ public static void main(String[] args) throws Exception {
+ String testclasses = System.getProperty("test.classes", ".");
+- List<Path> classes = new ArrayList<>();
+- classes.add(Paths.get(testclasses, "MissingCallerSensitive.class"));
++ List<File> classes = new ArrayList<File>();
++ classes.add(new File(testclasses, "MissingCallerSensitive.class"));
+
+ final String method = "sun/reflect/Reflection.getCallerClass";
+ CallerSensitiveFinder csfinder = new CallerSensitiveFinder(method);
diff --git a/java/openjdk6/files/icedtea/openjdk/oj6-20-merge.patch b/java/openjdk6/files/icedtea/openjdk/oj6-20-merge.patch
new file mode 100644
index 000000000000..e689c33d8a9f
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/oj6-20-merge.patch
@@ -0,0 +1,599 @@
+# HG changeset patch
+# User andrew
+# Date 1383034761 0
+# Tue Oct 29 08:19:21 2013 +0000
+# Node ID 05c35de6d7047c6d6d6e8edc402b7fab861d0a21
+# Parent efb24af909a020f3a3b3d446f6db15fc8b1c309a
+OPENJDK6-20: Resolve merge issues with JAXP security fixes
+Reviewed-by: omajid
+
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java Tue Oct 29 08:19:21 2013 +0000
+@@ -157,6 +157,25 @@
+ }
+
+ /**
++ * Return allowed protocols for accessing external stylesheet.
++ */
++ public Object getProperty(String name) {
++ if (name.equals(XalanConstants.SECURITY_MANAGER)) {
++ return _xmlSecurityManager;
++ }
++ return null;
++ }
++
++ /**
++ * Set allowed protocols for accessing external stylesheet.
++ */
++ public void setProperty(String name, Object value) {
++ if (name.equals(XalanConstants.SECURITY_MANAGER)) {
++ _xmlSecurityManager = (XMLSecurityManager)value;
++ }
++ }
++
++ /**
+ * Only for user by the internal TrAX implementation.
+ */
+ public Parser getParser() {
+@@ -901,23 +920,4 @@
+ return newDataOffset;
+ }
+
+- /**
+- * Return allowed protocols for accessing external stylesheet.
+- */
+- public Object getProperty(String name) {
+- if (name.equals(XalanConstants.SECURITY_MANAGER)) {
+- return _xmlSecurityManager;
+- }
+- return null;
+- }
+-
+- /**
+- * Set allowed protocols for accessing external stylesheet.
+- */
+- public void setProperty(String name, Object value) {
+- if (name.equals(XalanConstants.SECURITY_MANAGER)) {
+- _xmlSecurityManager = (XMLSecurityManager)value;
+- }
+- }
+-
+ }
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Tue Oct 29 08:19:21 2013 +0000
+@@ -283,6 +283,14 @@
+ } else if (name.equals(XalanConstants.SECURITY_MANAGER)) {
+ return _xmlSecurityManager;
+ }
++
++ /** Check to see if the property is managed by the security manager **/
++ String propertyValue = (_xmlSecurityManager != null) ?
++ _xmlSecurityManager.getLimitAsString(name) : null;
++ if (propertyValue != null) {
++ return propertyValue;
++ }
++
+ // Throw an exception for all other attributes
+ ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
+ throw new IllegalArgumentException(err.toString());
+@@ -383,6 +391,11 @@
+ }
+ }
+
++ if (_xmlSecurityManager != null &&
++ _xmlSecurityManager.setLimit(name, XMLSecurityManager.State.APIPROPERTY, value)) {
++ return;
++ }
++
+ // Throw an exception for all other attributes
+ final ErrorMsg err
+ = new ErrorMsg(ErrorMsg.JAXP_INVALID_ATTR_ERR, name);
+@@ -856,7 +869,13 @@
+ } else {
+ err = new ErrorMsg(ErrorMsg.JAXP_COMPILE_ERR);
+ }
+- TransformerConfigurationException exc = new TransformerConfigurationException(err.toString(), err.getCause());
++ Throwable cause = err.getCause();
++ TransformerConfigurationException exc;
++ if (cause != null) {
++ exc = new TransformerConfigurationException(cause.getMessage(), cause);
++ } else {
++ exc = new TransformerConfigurationException(err.toString());
++ }
+
+ // Pass compiler errors to the error listener
+ if (_errorListener != null) {
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Oct 29 08:19:21 2013 +0000
+@@ -179,6 +179,13 @@
+ return;
+ }
+
++ //check if the property is managed by security manager
++ if (fSecurityManager == null ||
++ !fSecurityManager.setLimit(property, XMLSecurityManager.State.APIPROPERTY, value)) {
++ //fall back to the existing property manager
++ supportedProps.put(property, value);
++ }
++
+ supportedProps.put(property, value ) ;
+ if(equivalentProperty != null){
+ supportedProps.put(equivalentProperty, value ) ;
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java Tue Oct 29 08:19:21 2013 +0000
+@@ -191,6 +191,9 @@
+
+ public void setFeature(String name, boolean value)
+ throws ParserConfigurationException {
++ if (features == null) {
++ features = new Hashtable();
++ }
+ // If this is the secure processing feature, save it then return.
+ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+ if (System.getSecurityManager() != null && (!value)) {
+@@ -199,11 +202,10 @@
+ "jaxp-secureprocessing-feature", null));
+ }
+ fSecureProcess = value;
++ features.put(name, value ? Boolean.TRUE : Boolean.FALSE);
+ return;
+ }
+- if (features == null) {
+- features = new Hashtable();
+- }
++
+ features.put(name, value ? Boolean.TRUE : Boolean.FALSE);
+ // Test the feature by possibly throwing SAX exceptions
+ try {
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java Tue Oct 29 08:19:21 2013 +0000
+@@ -253,12 +253,16 @@
+ }
+ }
+ } else {
+- // Let Xerces code handle the property
+- domParser.setProperty(name, val);
+- }
+- }
++ //check if the property is managed by security manager
++ if (fSecurityManager == null ||
++ !fSecurityManager.setLimit(name, XMLSecurityManager.State.APIPROPERTY, val)) {
++ //fall back to the existing property manager
++ domParser.setProperty(name, val);
++ }
+ }
++ }
+ }
++ }
+
+ /**
+ * Non-preferred: use the getDOMImplementation() method instead of this
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java Tue Oct 29 08:19:21 2013 +0000
+@@ -124,6 +124,7 @@
+ "jaxp-secureprocessing-feature", null));
+ }
+ fSecureProcess = value;
++ putInFeatures(name, value);
+ return;
+ }
+
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java Tue Oct 29 08:19:21 2013 +0000
+@@ -344,8 +344,10 @@
+ fSecurityManager = new XMLSecurityManager(true);
+ try {
+ super.setProperty(SECURITY_MANAGER, fSecurityManager);
+- } catch (Exception ex) {
+- //shall not happen
++ } catch (SAXException e) {
++ throw new UnsupportedOperationException(
++ SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
++ "property-not-recognized", new Object [] {SECURITY_MANAGER}), e);
+ }
+ }
+ }
+@@ -475,14 +477,21 @@
+ return;
+ }
+ }
+- if (!fInitProperties.containsKey(name)) {
+- fInitProperties.put(name, super.getProperty(name));
+- }
+ /** Forward property to the schema validator if there is one. **/
+ if (fSAXParser != null && fSAXParser.fSchemaValidator != null) {
+ setSchemaValidatorProperty(name, value);
+ }
+- super.setProperty(name, value);
++
++ //check if the property is managed by security manager
++ if (fSecurityManager == null ||
++ !fSecurityManager.setLimit(name, XMLSecurityManager.State.APIPROPERTY, value)) {
++ //fall back to the existing property manager
++ if (!fInitProperties.containsKey(name)) {
++ fInitProperties.put(name, super.getProperty(name));
++ }
++ super.setProperty(name, value);
++ }
++
+ }
+
+ public synchronized Object getProperty(String name)
+@@ -495,6 +504,14 @@
+ // JAXP 1.2 support
+ return fSAXParser.schemaLanguage;
+ }
++
++ /** Check to see if the property is managed by the security manager **/
++ String propertyValue = (fSecurityManager != null) ?
++ fSecurityManager.getLimitAsString(name) : null;
++ if (propertyValue != null) {
++ return propertyValue;
++ }
++
+ return super.getProperty(name);
+ }
+
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java Tue Oct 29 08:19:21 2013 +0000
+@@ -85,8 +85,7 @@
+ /*
+ * Other methods
+ */
+-
+- final void setFeature(String featureId, boolean state) {
++ public final void setFeature(String featureId, boolean state) {
+ fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
+ }
+
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java Tue Oct 29 08:19:21 2013 +0000
+@@ -239,6 +239,7 @@
+ else {
+ schema = new EmptyXMLSchema();
+ }
++ propagateProperties(schema);
+ propagateFeatures(schema);
+ return schema;
+ }
+@@ -247,6 +248,7 @@
+ // Use a Schema that uses the system id as the equality source.
+ AbstractXMLSchema schema = new WeakReferenceXMLSchema();
+ propagateFeatures(schema);
++ propagateProperties(schema);
+ return schema;
+ }
+
+@@ -322,7 +324,6 @@
+ "jaxp-secureprocessing-feature", null));
+ }
+
+- fSecurityManager = value ? new XMLSecurityManager() : null;
+ fSecurityManager.setSecureProcessing(value);
+ fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
+ return;
+@@ -362,7 +363,12 @@
+ "property-not-supported", new Object [] {name}));
+ }
+ try {
+- fXMLSchemaLoader.setProperty(name, object);
++ //check if the property is managed by security manager
++ if (fSecurityManager == null ||
++ !fSecurityManager.setLimit(name, XMLSecurityManager.State.APIPROPERTY, object)) {
++ //fall back to the existing property manager
++ fXMLSchemaLoader.setProperty(name, object);
++ }
+ }
+ catch (XMLConfigurationException e) {
+ String identifier = e.getIdentifier();
+@@ -388,6 +394,15 @@
+ }
+ }
+
++ private void propagateProperties(AbstractXMLSchema schema) {
++ String[] properties = fXMLSchemaLoader.getRecognizedProperties();
++ for (int i = 0; i < properties.length; ++i) {
++ Object state = fXMLSchemaLoader.getProperty(properties[i]);
++ schema.setProperty(properties[i], state);
++ }
++ }
++
++
+ /**
+ * Extension of XMLGrammarPoolImpl which exposes the number of
+ * grammars stored in the grammar pool.
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java Tue Oct 29 08:19:21 2013 +0000
+@@ -368,11 +368,15 @@
+ return;
+ }
+
+- //fall back to the existing property manager
+- if (!fInitProperties.containsKey(propertyId)) {
+- fInitProperties.put(propertyId, super.getProperty(propertyId));
++ //check if the property is managed by security manager
++ if (fInitSecurityManager == null ||
++ !fInitSecurityManager.setLimit(propertyId, XMLSecurityManager.State.APIPROPERTY, value)) {
++ //fall back to the existing property manager
++ if (!fInitProperties.containsKey(propertyId)) {
++ fInitProperties.put(propertyId, super.getProperty(propertyId));
++ }
++ super.setProperty(propertyId, value);
+ }
+- super.setProperty(propertyId, value);
+ }
+
+ /**
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java
+--- jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Oct 29 08:11:44 2013 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java Tue Oct 29 08:19:21 2013 +0000
+@@ -25,6 +25,8 @@
+ import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
+ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
+ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
++import org.xml.sax.SAXNotRecognizedException;
++import org.xml.sax.SAXNotSupportedException;
+
+ /**
+ * This is the main Xerces SAX parser class. It uses the abstract SAX
+@@ -125,4 +127,31 @@
+
+ } // <init>(SymbolTable,XMLGrammarPool)
+
++ /**
++ * Sets the particular property in the underlying implementation of
++ * org.xml.sax.XMLReader.
++ */
++ public void setProperty(String name, Object value)
++ throws SAXNotRecognizedException, SAXNotSupportedException {
++ /**
++ * It's possible for users to set a security manager through the interface.
++ * If it's the old SecurityManager, convert it to the new XMLSecurityManager
++ */
++ if (name.equals(Constants.SECURITY_MANAGER)) {
++ securityManager = XMLSecurityManager.convert(value, securityManager);
++ super.setProperty(Constants.SECURITY_MANAGER, securityManager);
++ return;
++ }
++
++ if (securityManager == null) {
++ securityManager = new XMLSecurityManager(true);
++ super.setProperty(Constants.SECURITY_MANAGER, securityManager);
++ }
++
++ //check if the property is managed by security manager
++ if (!securityManager.setLimit(name, XMLSecurityManager.State.APIPROPERTY, value)) {
++ //fall back to the default configuration to handle the property
++ super.setProperty(name, value);
++ }
++ }
+ } // class SAXParser
+diff -r efb24af909a0 -r 05c35de6d704 drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SecurityManager.java
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ jaxp/drop_included/jaxp_src/src/com/sun/org/apache/xerces/internal/util/SecurityManager.java Tue Oct 29 08:19:21 2013 +0000
+@@ -0,0 +1,215 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * The Apache Software License, Version 1.1
++ *
++ *
++ * Copyright (c) 2003 The Apache Software Foundation.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ *
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ *
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in
++ * the documentation and/or other materials provided with the
++ * distribution.
++ *
++ * 3. The end-user documentation included with the redistribution,
++ * if any, must include the following acknowledgment:
++ * "This product includes software developed by the
++ * Apache Software Foundation (http://www.apache.org/)."
++ * Alternately, this acknowledgment may appear in the software itself,
++ * if and wherever such third-party acknowledgments normally appear.
++ *
++ * 4. The names "Xerces" and "Apache Software Foundation" must
++ * not be used to endorse or promote products derived from this
++ * software without prior written permission. For written
++ * permission, please contact apache@apache.org.
++ *
++ * 5. Products derived from this software may not be called "Apache",
++ * nor may "Apache" appear in their name, without prior written
++ * permission of the Apache Software Foundation.
++ *
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
++ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
++ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
++ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
++ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
++ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
++ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ * ====================================================================
++ *
++ * This software consists of voluntary contributions made by many
++ * individuals on behalf of the Apache Software Foundation and was
++ * originally based on software copyright (c) 1999, International
++ * Business Machines, Inc., http://www.apache.org. For more
++ * information on the Apache Software Foundation, please see
++ * <http://www.apache.org/>.
++ */
++
++package com.sun.org.apache.xerces.internal.util;
++import com.sun.org.apache.xerces.internal.impl.Constants;
++/**
++ * This class is a container for parser settings that relate to
++ * security, or more specifically, it is intended to be used to prevent denial-of-service
++ * attacks from being launched against a system running Xerces.
++ * Any component that is aware of a denial-of-service attack that can arise
++ * from its processing of a certain kind of document may query its Component Manager
++ * for the property (http://apache.org/xml/properties/security-manager)
++ * whose value will be an instance of this class.
++ * If no value has been set for the property, the component should proceed in the "usual" (spec-compliant)
++ * manner. If a value has been set, then it must be the case that the component in
++ * question needs to know what method of this class to query. This class
++ * will provide defaults for all known security issues, but will also provide
++ * setters so that those values can be tailored by applications that care.
++ *
++ * @author Neil Graham, IBM
++ *
++ */
++public final class SecurityManager {
++
++ //
++ // Constants
++ //
++
++ // default value for entity expansion limit
++ private final static int DEFAULT_ENTITY_EXPANSION_LIMIT = 64000;
++
++ /** Default value of number of nodes created. **/
++ private final static int DEFAULT_MAX_OCCUR_NODE_LIMIT = 5000;
++
++ //
++ // Data
++ //
++
++ private final static int DEFAULT_ELEMENT_ATTRIBUTE_LIMIT = 10000;
++
++ /** Entity expansion limit. **/
++ private int entityExpansionLimit;
++
++ /** W3C XML Schema maxOccurs limit. **/
++ private int maxOccurLimit;
++
++ private int fElementAttributeLimit;
++ // default constructor. Establishes default values for
++ // all known security holes.
++ /**
++ * Default constructor. Establishes default values
++ * for known security vulnerabilities.
++ */
++ public SecurityManager() {
++ entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
++ maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT ;
++ fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
++ //We are reading system properties only once ,
++ //at the time of creation of this object ,
++ readSystemProperties();
++ }
++
++ /**
++ * <p>Sets the number of entity expansions that the
++ * parser should permit in a document.</p>
++ *
++ * @param limit the number of entity expansions
++ * permitted in a document
++ */
++ public void setEntityExpansionLimit(int limit) {
++ entityExpansionLimit = limit;
++ }
++
++ /**
++ * <p>Returns the number of entity expansions
++ * that the parser permits in a document.</p>
++ *
++ * @return the number of entity expansions
++ * permitted in a document
++ */
++ public int getEntityExpansionLimit() {
++ return entityExpansionLimit;
++ }
++
++ /**
++ * <p>Sets the limit of the number of content model nodes
++ * that may be created when building a grammar for a W3C
++ * XML Schema that contains maxOccurs attributes with values
++ * other than "unbounded".</p>
++ *
++ * @param limit the maximum value for maxOccurs other
++ * than "unbounded"
++ */
++ public void setMaxOccurNodeLimit(int limit){
++ maxOccurLimit = limit;
++ }
++
++ /**
++ * <p>Returns the limit of the number of content model nodes
++ * that may be created when building a grammar for a W3C
++ * XML Schema that contains maxOccurs attributes with values
++ * other than "unbounded".</p>
++ *
++ * @return the maximum value for maxOccurs other
++ * than "unbounded"
++ */
++ public int getMaxOccurNodeLimit(){
++ return maxOccurLimit;
++ }
++
++ public int getElementAttrLimit(){
++ return fElementAttributeLimit;
++ }
++
++ public void setElementAttrLimit(int limit){
++ fElementAttributeLimit = limit;
++ }
++
++ private void readSystemProperties(){
++
++ try {
++ String value = System.getProperty(Constants.ENTITY_EXPANSION_LIMIT);
++ if(value != null && !value.equals("")){
++ entityExpansionLimit = Integer.parseInt(value);
++ if (entityExpansionLimit < 0)
++ entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
++ }
++ else
++ entityExpansionLimit = DEFAULT_ENTITY_EXPANSION_LIMIT;
++ }catch(Exception ex){}
++
++ try {
++ String value = System.getProperty(Constants.MAX_OCCUR_LIMIT);
++ if(value != null && !value.equals("")){
++ maxOccurLimit = Integer.parseInt(value);
++ if (maxOccurLimit < 0)
++ maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
++ }
++ else
++ maxOccurLimit = DEFAULT_MAX_OCCUR_NODE_LIMIT;
++ }catch(Exception ex){}
++
++ try {
++ String value = System.getProperty(Constants.ELEMENT_ATTRIBUTE_LIMIT);
++ if(value != null && !value.equals("")){
++ fElementAttributeLimit = Integer.parseInt(value);
++ if ( fElementAttributeLimit < 0)
++ fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
++ }
++ else
++ fElementAttributeLimit = DEFAULT_ELEMENT_ATTRIBUTE_LIMIT;
++
++ }catch(Exception ex){}
++
++ }
++
++} // class SecurityManager
diff --git a/java/openjdk6/files/icedtea/openjdk/oj6-21-overrides.patch b/java/openjdk6/files/icedtea/openjdk/oj6-21-overrides.patch
new file mode 100644
index 000000000000..797a4f63f305
--- /dev/null
+++ b/java/openjdk6/files/icedtea/openjdk/oj6-21-overrides.patch
@@ -0,0 +1,20 @@
+# HG changeset patch
+# User andrew
+# Date 1383055466 0
+# Tue Oct 29 14:04:26 2013 +0000
+# Node ID 4a15d8b1c94aa5e5a9c61bbd0feb7a6727343927
+# Parent f587451cfca426297a5d9be67c7bfc36f1ad8e10
+OPENJDK6-21: Remove @Override annotation added on interface by 2013/10/15 security fixes
+Reviewed-by: omajid
+
+diff -r f587451cfca4 -r 4a15d8b1c94a src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java
+--- corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java Tue Oct 15 15:55:15 2013 +0100
++++ corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/InvocationHandlerFactoryImpl.java Tue Oct 29 14:04:26 2013 +0000
+@@ -130,7 +130,6 @@
+ new CustomCompositeInvocationHandlerImpl( stub ) ;
+
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+- @Override
+ public Void run() {
+ handler.addInvocationHandler( DynamicStub.class,
+ dynamicStubHandler ) ;
diff --git a/java/openjdk6/files/patch-set b/java/openjdk6/files/patch-set
index 22157d014f6b..405fc9df13aa 100644
--- a/java/openjdk6/files/patch-set
+++ b/java/openjdk6/files/patch-set
@@ -595,15 +595,7 @@
define_pd_global(intx, CMSYoungGenPerWorker, 64*M); // default max size of CMS young gen, per GC worker thread
--- hotspot/src/os/bsd/vm/jvm_bsd.cpp
+++ hotspot/src/os/bsd/vm/jvm_bsd.cpp
-@@ -50,6 +50,7 @@
- case INTERRUPT_SIGNAL:
- case SIGFPE:
- case SIGILL:
-+ case SIGBUS:
- case SIGSEGV:
-
- /* The following signal is used by the VM to dump thread stacks unless
-@@ -110,71 +111,29 @@
+@@ -110,71 +110,30 @@
JVM_END
/*
@@ -625,8 +617,9 @@
- CLD, CHLD, CONT, TSTP, TTIN, TTOU, URG, XCPU, XFSZ, VTALRM, PROF,
- WINCH, POLL, IO, PWR, SYS
-
-+ HUP, INT, TRAP, ABRT, EMT, SYS, PIPE, ALRM, TERM, URG, TSTP, CONT,
-+ CHLD, TTIN, TTOU, IO, XCPU, XFSZ, VTALRM, PROF, WINCH, INFO, USR2
++ HUP, INT, TRAP, ABRT, EMT, BUS, SYS, PIPE, ALRM, TERM, URG, TSTP,
++ CONT, CHLD, TTIN, TTOU, IO, XCPU, XFSZ, VTALRM, PROF, WINCH, INFO,
++ USR2
*/
-struct siglabel {
@@ -787,31 +780,7 @@
#if defined(__FreeBSD__) || defined(__NetBSD__)
# include <elf.h>
#endif
-@@ -162,8 +174,10 @@
- #endif
-
- int (*os::Bsd::_clock_gettime)(clockid_t, struct timespec *) = NULL;
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- int (*os::Bsd::_pthread_getcpuclockid)(pthread_t, clockid_t *) = NULL;
-+#endif
-+#ifndef _ALLBSD_SOURCE
- Mutex* os::Bsd::_createThread_lock = NULL;
- #endif
- pthread_t os::Bsd::_main_thread;
-@@ -171,7 +185,11 @@
- #ifndef _ALLBSD_SOURCE
- bool os::Bsd::_is_floating_stack = false;
- bool os::Bsd::_is_NPTL = false;
-+#endif
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- bool os::Bsd::_supports_fast_thread_cpu_time = false;
-+#endif
-+#ifndef _ALLBSD_SOURCE
- const char * os::Bsd::_glibc_version = NULL;
- const char * os::Bsd::_libpthread_version = NULL;
- #endif
-@@ -205,6 +223,28 @@
+@@ -205,6 +217,28 @@
julong os::Bsd::available_memory() {
#ifdef _ALLBSD_SOURCE
@@ -840,7 +809,7 @@
// XXXBSD: this is just a stopgap implementation
return physical_memory() >> 2;
#else
-@@ -221,6 +261,17 @@
+@@ -221,6 +255,17 @@
}
julong os::allocatable_physical_memory(julong size) {
@@ -858,7 +827,7 @@
#ifdef _LP64
return size;
#else
-@@ -308,16 +359,22 @@
+@@ -308,16 +353,22 @@
#define COMPILER_VARIANT "client"
#endif
@@ -885,7 +854,7 @@
int rslt = syscall(SYS_gettid);
if (rslt == -1) {
// old kernel, no NPTL support
-@@ -325,6 +382,7 @@
+@@ -325,6 +376,7 @@
} else {
return (pid_t)rslt;
}
@@ -893,7 +862,7 @@
}
// Most versions of bsd have a bug where the number of processors are
-@@ -337,7 +395,35 @@
+@@ -337,7 +389,35 @@
"environment on Bsd when /proc filesystem is not mounted.";
#endif
@@ -930,7 +899,7 @@
void os::Bsd::initialize_system_info() {
int mib[2];
size_t len;
-@@ -452,7 +538,7 @@
+@@ -452,7 +532,7 @@
* 7: The default directories, normally /lib and /usr/lib.
*/
#ifndef DEFAULT_LIBPATH
@@ -939,7 +908,7 @@
#endif
#define EXTENSIONS_DIR "/lib/ext"
-@@ -997,7 +1083,7 @@
+@@ -997,7 +1077,7 @@
return NULL;
}
@@ -948,7 +917,7 @@
#ifdef __APPLE__
// thread_id is mach thread on macos
osthread->set_thread_id(::mach_thread_self());
-@@ -1009,6 +1095,7 @@
+@@ -1009,6 +1089,7 @@
// thread_id is kernel thread id (similar to Solaris LWP id)
osthread->set_thread_id(os::Bsd::gettid());
@@ -956,7 +925,7 @@
if (UseNUMA) {
int lgrp_id = os::numa_get_group_id();
if (lgrp_id != -1) {
-@@ -1016,6 +1103,7 @@
+@@ -1016,6 +1097,7 @@
}
}
#endif
@@ -964,16 +933,7 @@
// initialize signal mask for this thread
os::Bsd::hotspot_sigmask(thread);
-@@ -1105,7 +1193,7 @@
- // let pthread_create() pick the default value.
- }
-
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- // glibc guard page
- pthread_attr_setguardsize(&attr, os::Bsd::default_guard_size(thr_type));
- #endif
-@@ -1194,7 +1282,7 @@
+@@ -1194,7 +1276,7 @@
}
// Store pthread info into the OSThread
@@ -982,27 +942,7 @@
#ifdef __APPLE__
osthread->set_thread_id(::mach_thread_self());
#else
-@@ -1630,7 +1718,10 @@
- }
- #endif
-
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
-+#ifdef __FreeBSD__
-+#define sys_clock_getres clock_getres
-+#else
- #ifndef SYS_clock_getres
-
- #if defined(IA32) || defined(AMD64)
-@@ -1644,6 +1735,7 @@
- #else
- #define sys_clock_getres(x,y) ::syscall(SYS_clock_getres, x, y)
- #endif
-+#endif
-
- void os::Bsd::fast_thread_clock_init() {
- if (!UseBsdPosixThreadCPUClocks) {
-@@ -1817,8 +1909,10 @@
+@@ -1817,8 +1899,10 @@
}
intx os::current_thread_id() {
@@ -1014,7 +954,7 @@
#else
return (intx)::pthread_self();
#endif
-@@ -2341,14 +2435,16 @@
+@@ -2341,14 +2425,16 @@
}
void os::print_os_info_brief(outputStream* st) {
@@ -1033,7 +973,7 @@
os::Posix::print_uname_info(st);
-@@ -2366,7 +2462,23 @@
+@@ -2366,7 +2452,23 @@
st->print("Memory:");
st->print(" %dk page", os::vm_page_size()>>10);
@@ -1058,7 +998,7 @@
// values in struct sysinfo are "unsigned long"
struct sysinfo si;
sysinfo(&si);
-@@ -2376,17 +2488,22 @@
+@@ -2376,17 +2478,22 @@
os::physical_memory() >> 10);
st->print("(" UINT64_FORMAT "k free)",
os::available_memory() >> 10);
@@ -1083,25 +1023,7 @@
st->cr();
}
-@@ -2399,7 +2516,7 @@
-
- const char *fpe_names[] = { "FPE0", "FPE_INTDIV", "FPE_INTOVF", "FPE_FLTDIV",
- "FPE_FLTOVF", "FPE_FLTUND", "FPE_FLTRES",
-- "FPE_FLTINV", "FPE_FLTSUB", "FPE_FLTDEN" };
-+ "FPE_FLTINV", "FPE_FLTSUB" };
-
- const char *segv_names[] = { "SEGV0", "SEGV_MAPERR", "SEGV_ACCERR" };
-
-@@ -2425,7 +2542,7 @@
- st->print(", si_addr=" PTR_FORMAT, si->si_addr);
- break;
- case SIGFPE:
-- st->print(", si_code=%d (%s)", c, c > 9 ? "" : fpe_names[c]);
-+ st->print(", si_code=%d (%s)", c, c > 8 ? "" : fpe_names[c]);
- st->print(", si_addr=" PTR_FORMAT, si->si_addr);
- break;
- case SIGSEGV:
-@@ -2533,10 +2650,17 @@
+@@ -2533,10 +2640,17 @@
jrelib_p = buf + len;
// Add the appropriate library subdir
@@ -1119,7 +1041,7 @@
// Add the appropriate client or server subdir
len = strlen(buf);
-@@ -2997,9 +3121,10 @@
+@@ -2997,9 +3111,10 @@
flags |= MAP_FIXED;
}
@@ -1133,7 +1055,7 @@
flags, -1, 0);
if (addr != MAP_FAILED) {
-@@ -3156,7 +3281,9 @@
+@@ -3156,7 +3271,9 @@
static size_t _large_page_size = 0;
void os::large_page_init() {
@@ -1144,7 +1066,7 @@
if (!UseLargePages) {
UseHugeTLBFS = false;
UseSHM = false;
-@@ -3654,8 +3781,8 @@
+@@ -3654,8 +3771,8 @@
return OS_OK;
#else
int ret = setpriority(PRIO_PROCESS, thread->osthread()->thread_id(), newpri);
@@ -1154,25 +1076,7 @@
}
OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) {
-@@ -4171,7 +4298,7 @@
- }
- }
-
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- // This is the fastest way to get thread cpu time on Bsd.
- // Returns cpu time (user+sys) for any thread, not only for current.
- // POSIX compliant clocks are implemented in the kernels 2.6.16+.
-@@ -4450,7 +4577,7 @@
- // this is called _after_ the global arguments have been parsed
- jint os::init_2(void)
- {
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- Bsd::fast_thread_clock_init();
- #endif
-
-@@ -4634,6 +4761,20 @@
+@@ -4634,6 +4751,20 @@
int os::active_processor_count() {
#ifdef _ALLBSD_SOURCE
@@ -1193,110 +1097,9 @@
return _processor_count;
#else
// Bsd doesn't yet have a (official) notion of processor sets,
-@@ -5033,7 +5174,7 @@
- return munmap(addr, bytes) == 0;
- }
-
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time);
-
- static clockid_t thread_cpu_clockid(Thread* thread) {
-@@ -5057,7 +5198,7 @@
- jlong os::current_thread_cpu_time() {
- #ifdef __APPLE__
- return os::thread_cpu_time(Thread::current(), true /* user + sys */);
--#elif !defined(_ALLBSD_SOURCE)
-+#elif !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- if (os::Bsd::supports_fast_thread_cpu_time()) {
- return os::Bsd::fast_thread_cpu_time(CLOCK_THREAD_CPUTIME_ID);
- } else {
-@@ -5068,7 +5209,7 @@
- }
-
- jlong os::thread_cpu_time(Thread* thread) {
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- // consistent with what current_thread_cpu_time() returns
- if (os::Bsd::supports_fast_thread_cpu_time()) {
- return os::Bsd::fast_thread_cpu_time(thread_cpu_clockid(thread));
-@@ -5081,7 +5222,7 @@
- jlong os::current_thread_cpu_time(bool user_sys_cpu_time) {
- #ifdef __APPLE__
- return os::thread_cpu_time(Thread::current(), user_sys_cpu_time);
--#elif !defined(_ALLBSD_SOURCE)
-+#elif !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- if (user_sys_cpu_time && os::Bsd::supports_fast_thread_cpu_time()) {
- return os::Bsd::fast_thread_cpu_time(CLOCK_THREAD_CPUTIME_ID);
- } else {
-@@ -5110,7 +5251,7 @@
- } else {
- return ((jlong)tinfo.user_time.seconds * 1000000000) + ((jlong)tinfo.user_time.microseconds * (jlong)1000);
- }
--#elif !defined(_ALLBSD_SOURCE)
-+#elif !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- if (user_sys_cpu_time && os::Bsd::supports_fast_thread_cpu_time()) {
- return os::Bsd::fast_thread_cpu_time(thread_cpu_clockid(thread));
- } else {
-@@ -5119,12 +5260,15 @@
- #endif
- }
-
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- //
- // -1 on error.
- //
-
- static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
-+#ifdef __FreeBSD__
-+ return -1;
-+#else
- static bool proc_pid_cpu_avail = true;
- static bool proc_task_unchecked = true;
- static const char *proc_stat_path = "/proc/%d/stat";
-@@ -5208,6 +5352,7 @@
- } else {
- return (jlong)user_time * (1000000000 / clock_tics_per_sec);
- }
-+#endif
- }
- #endif
-
-@@ -5226,7 +5371,7 @@
- }
-
- bool os::is_thread_cpu_time_supported() {
--#ifdef __APPLE__
-+#if defined(__APPLE__) || defined(__FreeBSD__)
- return true;
- #elif defined(_ALLBSD_SOURCE)
- return false;
--- hotspot/src/os/bsd/vm/os_bsd.hpp
+++ hotspot/src/os/bsd/vm/os_bsd.hpp
-@@ -56,9 +56,11 @@
- static int sigflags[MAXSIGNUM];
-
- static int (*_clock_gettime)(clockid_t, struct timespec *);
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- static int (*_pthread_getcpuclockid)(pthread_t, clockid_t *);
-+#endif
-
-+#ifndef _ALLBSD_SOURCE
- static address _initial_thread_stack_bottom;
- static uintptr_t _initial_thread_stack_size;
-
-@@ -67,6 +69,8 @@
-
- static bool _is_floating_stack;
- static bool _is_NPTL;
-+#endif
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- static bool _supports_fast_thread_cpu_time;
- #endif
-
-@@ -112,13 +116,15 @@
+@@ -112,13 +112,15 @@
#endif
static pthread_t main_thread(void) { return _main_thread; }
@@ -1313,13 +1116,7 @@
static void hotspot_sigmask(Thread* thread);
#ifndef _ALLBSD_SOURCE
-@@ -197,12 +203,12 @@
- // Real-time clock functions
- static void clock_init(void);
-
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- // fast POSIX clocks support
+@@ -202,7 +204,7 @@
static void fast_thread_clock_init(void);
#endif
@@ -1328,15 +1125,6 @@
return _clock_gettime != NULL;
}
-@@ -210,7 +216,7 @@
- return _clock_gettime ? _clock_gettime(clock_id, tp) : -1;
- }
-
--#ifndef _ALLBSD_SOURCE
-+#if !defined(_ALLBSD_SOURCE) || defined(__FreeBSD__)
- static int pthread_getcpuclockid(pthread_t tid, clockid_t *clock_id) {
- return _pthread_getcpuclockid ? _pthread_getcpuclockid(tid, clock_id) : -1;
- }
--- hotspot/src/os/bsd/vm/threadCritical_bsd.cpp
+++ hotspot/src/os/bsd/vm/threadCritical_bsd.cpp
@@ -33,35 +33,36 @@
@@ -2157,17 +1945,6 @@
void* result = (void*) tp->area_top;
tp->area_top += size;
---- hotspot/src/share/vm/runtime/globals.hpp
-+++ hotspot/src/share/vm/runtime/globals.hpp
-@@ -1125,7 +1125,7 @@
- product(intx, hashCode, 0, \
- "(Unstable) select hashCode generation algorithm" ) \
- \
-- product(intx, WorkAroundNPTLTimedWaitHang, 1, \
-+ product(intx, WorkAroundNPTLTimedWaitHang, 0, \
- "(Unstable, Linux-specific)" \
- " avoid NPTL-FUTEX hang pthread_cond_timedwait" ) \
- \
--- hotspot/src/share/vm/runtime/interfaceSupport.hpp
+++ hotspot/src/share/vm/runtime/interfaceSupport.hpp
@@ -67,7 +67,7 @@